-
Notifications
You must be signed in to change notification settings - Fork 23
Implement a callback function for DatetimeRotatingFileLogger. #42
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
Conversation
|
On second thought, function callback(file::String)
# do stuff
endis probably enough. The directory you can get from using Logging, LoggingExtras
const pattern = raw"yyyy-mm-dd.\l\o\g"
function callback(file)
# do something with `file` and global `pattern`
end
logger = DatetimeFileRotatingLogger(dir, pattern; callback=callback) |
0dc26b4 to
06936e8
Compare
oxinabox
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
this is useful and make a lot of sense as a thing to have.
Some fairly minor comments. but basically looks good.
ebe5a1f to
0b378cc
Compare
|
Hmm why is CI failing here, saying it was only rotated once? |
149d2f0 to
ce1ff73
Compare
|
Yea I was just discussing this with @staticfloat and basically allowing to rotate for so small time-scales is not very robust. Our idea (which is implemented in the last commit) is to just error for sub-minute resolution. I think this is fine since I believe in real life one wouldn't use this for sub-day resolution, possibly hour-level. Thoughts? |
|
Yeah could do. Or use Mocking.jl / SimpleMock.jl to mock the call to |
|
Yea the sleeping now should have ~5 seconds of margin |
|
Thanks |
This allows passing a callback that is called with the previous file whenever the logger rotates the backing file. Example callback to compress the logfile: