-
Notifications
You must be signed in to change notification settings - Fork 25
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
Tee all logs to user log directory #318
Conversation
Codecov Report
@@ Coverage Diff @@
## master #318 +/- ##
==========================================
- Coverage 81.72% 81.52% -0.20%
==========================================
Files 54 54
Lines 4979 5002 +23
==========================================
+ Hits 4069 4078 +9
- Misses 910 924 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
minor wish: uniform formatting within the log, so initial entries should also follow the format
dandi/cli/command.py
Outdated
os.makedirs(logdir, exist_ok=True) | ||
with open(logfile, "w") as fp: | ||
print("sys.argv =", sys.argv, file=fp) | ||
print("os.getcwd() =", os.getcwd(), file=fp) |
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.
Please write them in the same format as log messages - would simplify parsing of those files of needed
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.
May be you even could just emit necessary records to the handler you create below to make it log in the desired format?
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.
Done (kind of kludgily).
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.
thanks! I think there should indeed be a better way (see e.g. how we handle filtering out of progress indication log messages in datalad: https://github.com/datalad/datalad/blob/master/datalad/log.py#L262 ) but let's proceed.
@yarikoptic I've figured out a way to ensure that the log file path is always printed, even on error. |
Closes #316
Unfortunately, if the program exits abnormally, the final message giving the location of the logfile won't be printed. I'm not aware of a way around this.