looking for recommendation: which thread safe logger library?

Danilo codedan at aol.com
Wed Jul 12 04:48:23 UTC 2023


On Wednesday, 12 July 2023 at 01:55:00 UTC, mw wrote:
> ```
> import std.experimental.logger;
>
> void main() {
>     std.experimental.logger.sharedLog.trace("msg");
> }
> ```

See examples at https://dlang.org/phobos/std_logger.html
and https://dlang.org/phobos/std_logger_filelogger.html

```d
import std.stdio;
import std.logger;

void main() {
     //auto file = File("logFile.log", "w");
     auto file = stderr; // stdout

     auto logger = new FileLogger(file);
     //auto logger = new FileLogger(file, LogLevel.fatal);

     logger.log("log message");
     logger.info("info message");
     logger.warning(5 < 6, "Logging with LogLevel.warning if 5 is 
less than 6");
     logger.warningf(5 < 6, "Logging with LogLevel.warning if %s 
is %s than 6", 5, "less");
     logger.critical("Logging with critical LogLevel");
     logger.log(LogLevel.trace, 5 < 6, "Logging"," with its 
default LogLevel if 5 is less than 6");
     //logger.fatal("fatal message");
}
```



More information about the Digitalmars-d-learn mailing list