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

Tee all logs to user log directory #318

Merged
merged 4 commits into from
Dec 16, 2020
Merged

Tee all logs to user log directory #318

merged 4 commits into from
Dec 16, 2020

Conversation

jwodder
Copy link
Member

@jwodder jwodder commented Dec 14, 2020

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.

@jwodder jwodder added the patch Increment the patch version when merged label Dec 14, 2020
@codecov
Copy link

codecov bot commented Dec 14, 2020

Codecov Report

Merging #318 (b5bbd1d) into master (178e806) will decrease coverage by 0.19%.
The diff coverage is 44.00%.

Impacted file tree graph

@@            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     
Flag Coverage Δ
unittests 81.52% <44.00%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
dandi/cli/command.py 45.20% <38.09%> (-3.86%) ⬇️
dandi/cli/base.py 77.35% <75.00%> (-0.65%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 178e806...b5bbd1d. Read the comment docs.

Copy link
Member

@yarikoptic yarikoptic left a 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

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)
Copy link
Member

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

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done (kind of kludgily).

Copy link
Member

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.

@jwodder
Copy link
Member Author

jwodder commented Dec 15, 2020

@yarikoptic I've figured out a way to ensure that the log file path is always printed, even on error.

@yarikoptic yarikoptic merged commit d21b154 into master Dec 16, 2020
@yarikoptic yarikoptic deleted the gh-316 branch December 16, 2020 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch Increment the patch version when merged
Projects
None yet
2 participants