digitalmars.D.learn - How to use isLoggingEnabled?
- Andre Pany (32/33) Sep 21 2020 Hi,
Hi, I am confused by the description of isLoggingEnabled. In my unittest version I want to disable logging and use this command: ``` d sharedLog = new NullLogger(LogLevel.off); ``` If have some stdout writeln coding (to avoid the timestamp / module prefix): ``` d private void printRuntimeLog(string logFilePath) { import std.stdio : stdout; if (isLoggingEnabled(LogLevel.info)) { logFilePath.readText.strip.splitLines.map!(line => "[runtime-log] " ~ line).each!(line => stdout.writeln(line)); stdout.flush; } } ``` I just want to check whether LogLevel.info or more is active. But the method isLoggingEnabled seems to expect the LogLevel 3 times? ``` safe bool isLoggingEnabled()(LogLevel ll, LogLevel loggerLL, LogLevel globalLL, lazy bool condition = true); ``` Another strange thing is, the description of isLogginEnabled (https://dlang.org/phobos/std_experimental_logger_core.html#.isLoggingEnabled) mentions a call with only 1 logLevel argument, but this method does not seems to exist:pure bool isLoggingEnabled()(LogLevel ll) safe nothrow nogcIs there an easy way to check if log level is "info" or more? Kind regards André
Sep 21 2020