LoggingExtras.jl icon indicating copy to clipboard operation
LoggingExtras.jl copied to clipboard

FileLogger add level argument to match SimpleLogger

Open sjdaines opened this issue 2 years ago • 1 comments

With Logging.SimpleLogger you can do

SimpleLogger(logstream, Logging.Info)

It would be convenient if LoggingExtras.FileLogger allowed level to be set in the same way so it works as a drop-in replacement, ie

FileLogger(logstream, Logging.Info)
FileLogger("my_logfile.txt", Logging.Info)

edit: perhaps this is just a documentation request, the equivalent is (?):

LoggingExtras.MinLevelLogger(
    LoggingExtras.FileLogger(logstream, always_flush=true),
    Logging.Info
)

sjdaines avatar Jul 30 '23 13:07 sjdaines

This is indeed exactly equivalent to wrapping in a MinLevelLogger, and that is the preferred way to do this. Feel free to open a documentation PR, that would make a decent example to add under the MinLevelLogger

oxinabox avatar Aug 08 '23 08:08 oxinabox