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
log: Added support to include date-time in log filename #7697
base: master
Are you sure you want to change the base?
log: Added support to include date-time in log filename #7697
Conversation
Added a flag `log-file-time-format` that allows specifying a date-time format that is used to replace the `:dt:` wildcard in the filename of the log file.
This is a nice idea. A couple of thoughts
This might lead to a UI which looked like What do you think @HikaruHokkyokusei ? @nielash do you have any thoughts? |
I did something just like this recently (actually twice!) Maybe this should be factored out as a rclone/fs/operations/operations.go Lines 2106 to 2156 in 2bebbfa
rclone/cmd/bisync/bilib/names.go Lines 107 to 165 in 2bebbfa
|
@nielash Thanks for pointing out the specific code where you have implemented this. @ncw , Here is why I believe we cannot reuse the code provided by @nielash : - Also, thanks for pointing out go-strftime repo. I had come across it before, but didn't know if we were allowed to use external libs. I believe this is the best approach so I will replace my implementation with I will take a look at other places that you have mentioned in point number 3 and let you know @ncw . Yep, the idea of a dynamic wildcard (instead of just using |
So with this commit, I have taken care of the custom wildcard and replaced the formatting methodology with the @ncw , I looked into I do not know the frequency of how many times these values are referred to. The logging file was created once, so that was straightforward. One idea I had was to set the value for In this This way, one specific value will be set for |
I think your solution is fine, but just to clarify one thing:
This issue is specifically addressed in bisync's Lines 628 to 635 in f62e7b5
and also allowing the user to specify their own custom format: rclone/cmd/bisync/bilib/names.go Line 154 in 2bebbfa
That said, I agree that |
Changed the flag for filename timestamp format from `log-file-time-format` to `file-time-format`. It now allows user to specify `WILDCARD` along with the format. Also, the formatting is now done by `go-strftime` library.
0bd81ab
to
fc7ba18
Compare
@ncw , would be great if you could provide some insight about how to move forward with |
Sorry for the delay merging @HikaruHokkyokusei I think the code and implementation looks great but I'd like to discuss exactly what this looks like as these things are very difficult to change once released! We have at the moment I'm thinking ahead a bit here, but I'd like to re-use this syntax in So up for discussion
Any thoughts welcome (@nielash and @albertony also) |
Added a flag
log-file-time-format
that allows specifying a date-time format that is used to replace the:dt:
wildcard in the filename of the log file.What is the purpose of this change?
This change allows users to specify a Date-time Format string for a new flag
log-file-time-format
. A datetime string is generated using this format that replaces the wildcard:dt:
in the log filename. This change is required for a specific scenario: -By default, rclone always appends (not overwrite) logs to a file. This is the same with cases when a Windows Service is created to allow rclone to run in the background while mounting. Based on the logging level, these logs can be huge and one might not prefer them getting appended to the same file every time the mount command is used (say after the device is restarted). Making dynamic filename (in the context of Windows Service) is a tricky challenge, as the
%....%
variable templates are not replaced with the actual values.This change allows users to now use dynamic filenames based on the date and time of each session of the rclone.
Was the change discussed in an issue or in the forum before?
While the change has not been discussed in any issues, a couple of users have talked in the context of similar requirements in the forums.
https://forum.rclone.org/t/dynamically-create-log-file-with-date-in-the-name/27603
https://forum.rclone.org/t/rclone-win2019-scheduled-tasks-date-in-logfile/33232
Checklist