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

Should FileLogger close the io stream somehow? #86

Closed
ericphanson opened this issue Dec 8, 2023 · 3 comments
Closed

Should FileLogger close the io stream somehow? #86

ericphanson opened this issue Dec 8, 2023 · 3 comments

Comments

@ericphanson
Copy link
Member

filehandle = open(path, append ? "a" : "w")
FileLogger(filehandle; kwargs...)

Perhaps atexit(() -> close(io)) would be appropriate?

I have not seen any bugs from the current implementation, but I do worry one could lose logs when always_flush=false.

@fredrikekre
Copy link
Member

I believe open files are closed when Julia exits (at least if it doesn't crash, but then I don't think atexit hooks would run either).

@ericphanson
Copy link
Member Author

Ah I guess that's https://github.com/JuliaLang/julia/blob/5dfaef7a67c9b58ed272ba8557bcad103bb814e3/base/iostream.jl#L28 or similar?

Probably another reason JuliaLang/julia#51466 is dangerous then. But I guess it is safe for now, as long as we keep running finalizers on exit

@oxinabox
Copy link
Member

oxinabox commented Dec 14, 2023

the fear of losing logs due to a hard-crash when always_flush is false, is exactly why we provide the always_flush flag.

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