Action based on the current loglevel

I want to add logging which need some more expensive operations before. Let's say I want to retrieve extra entities, count them or other things and use this information in the log action. I log this at debug level. If the lognode is higher than debug, there is no need to do all this extra operations, since it is only used in the logaction itself. In Java you could use the isLoggable() method from the log api for this, are there any solutions for this in Mendix?  
1 answers

I feel like this should be a java action in CommunityCommons. It could be something like this:

Given an input "LogNode", it should return an enum with the max current log level of all log subscribers (since there can be more than 1).

ILogNode logger = Core.getLogger(LogNode);
Collection<LogLevel> currentSubscriptionLevels = logger.getSubscribers().values();
LogLevel maxLevel = Collections.max(currentSubscriptionLevels);
return maxLevel.toString();

Perhaps you or someone else can work this into a Java action, and then we could add it to CommunityCommons.