Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example mixing FileLogger and FormatLogger ? #48

Closed
BambOoxX opened this issue May 6, 2021 · 2 comments
Closed

Add an example mixing FileLogger and FormatLogger ? #48

BambOoxX opened this issue May 6, 2021 · 2 comments

Comments

@BambOoxX
Copy link

BambOoxX commented May 6, 2021

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.

@oxinabox
Copy link
Member

oxinabox commented May 6, 2021

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.

@oxinabox oxinabox closed this as completed May 6, 2021
@oxinabox oxinabox reopened this May 6, 2021
@fredrikekre
Copy link
Member

fredrikekre commented May 6, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants