JuliaLogging / LoggingExtras.jl

Composable Loggers for the Julia Logging StdLib

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add an example mixing FileLogger and FormatLogger ?

BambOoxX opened this issue · comments

I just asked a question on the julia discource about this here, but this may be considered for a documentation improvement too, probably in the "More examples" section. Otherwise, this is very nice work.

I think you probably just want an example of using FormatLogger on a file?

That would indeed be a reasonable example.

It is just
FormatLogger(fmt, open("myfile.log", "w"))

We could add that example to the docs. Would be good.
Probably also worth documenting that the FileLogger is nothing more than a thin logging sink around a stream.

It would be possible to define

function FormatLogger(f::Function, file::AbstractString; append=false, kwargs...)
    io = open(file, append ? "a" : "w")
    return FormatLogger(f, io; kwargs...)
end

but perhaps that puts "too much" functionality into the FormatLogger, and might be clearer to just open the file yourself.