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

Always same filename of active logfile in DatetimeRotatingFilelogger, until rotated out #52

Open
fredrikekre opened this issue Jun 3, 2021 · 2 comments

Comments

@fredrikekre
Copy link
Member

Currently the timestamp is added to the active logger and not just when changing log files. logrotate only appends the timestamp when rotating the file such that the active file is always the same. This behavior is sometimes useful and I think it would be good to support that there too. It is very easy to implement, but I am just not sure what the API should be. Perhaps just a filename and a prefix as two arguments?

@oxinabox oxinabox changed the title Filename of active logfile in DatetimeRotatingFilelogger Always same filename of active logfile in DatetimeRotatingFilelogger, until rotated out Sep 21, 2021
@oxinabox
Copy link
Member

Would that be a better option than the current way?
It would be nice to avoid having configurable options, and have one consistent way it always worked.

I am just not sure what the API should be. Perhaps just a filename and a prefix as two arguments?

It would be nice to keep the current API, where you pass a DateFormat, I think.
I feel like a we could derive a simple filename from the DateFormat.

julia> fmt = DateFormat(raw"\a\c\c\e\s\s-yyyy-mm-dd.\l\o\g")
dateformat"acc\e\s\s-yyyy-mm-dd.log"

julia> fmt.tokens
(Delim(acc\e\s\s-), DatePart(yyyy), Delim(-), DatePart(mm), Delim(-), DatePart(dd), Delim(.log))
  • Either very simply by juust dropping the the DateParts, which would end up with access---.log
  • or a bit more complex where we drop Delims that are only non-alphanums when they occur between DateParts: that would give use access-.log
  • or even more complex: when adjacent to DateParts, except for if they are in the last Delim and are ., which would get us to access-.log

but all the above heuristics fail for:

julia> fmt = DateFormat(raw"\a\c\c\e\s\s-\yYY-\mMM.\l\o\g")
dateformat"acc\e\s\s-\yYY-\mMM.log"

Which is a reasonable format of access-y21-09.log which even the last will reduce to access-ym.log.
But maybe something more complex could do it?
Or maybe something simplete, of just keeping first and last Delim ?

@fredrikekre
Copy link
Member Author

Would that be a better option than the current way?

The motivation for this issue is tools that monitor a log file. I worked around this issue by just using the rotation_callback function to create a symlink. I can post the workaround when I have access to that computer again. Might be simple enough to do it like that.

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

2 participants