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

Add FAQ entry for changing the date format #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arnaudh
Copy link
Contributor

@arnaudh arnaudh commented Jul 16, 2021

I and at least one other person have needed this, I'm guessing it's common enough to have a FAQ entry.

Just not sure of the proposed solution, but this works for my case (changes the console handler for the root logger).
Should we suggest to the reader to do this for every handler they have? Unsure if/how the handlers & formatters get re-used in the logger hierarchy.

@codecov
Copy link

codecov bot commented Jul 16, 2021

Codecov Report

Merging #178 (169848a) into master (b557fed) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #178   +/-   ##
=======================================
  Coverage   98.23%   98.23%           
=======================================
  Files          13       13           
  Lines         396      396           
=======================================
  Hits          389      389           
  Misses          7        7           

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 b557fed...169848a. Read the comment docs.


```julia
# Changes the formatter of the console handler of the root logger
gethandlers(getlogger())["console"].fmt = DefaultFormatter("[{date} | {name} | {level}]: {msg}"; date_fmt_string="yyyy-mm-dd HH:MM:SS.sss")
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we actively want to support this approach, as it seems too easy to break. My recommendation would be to either refactor this package to support passing a dateformat kwarg to config! or explicitly mutate Memento._loggers["root"] = Logger(...) to reduce how much you're accessing private fields/components. At some point this package will require a refactor to make things less nested.

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

Successfully merging this pull request may close these issues.

2 participants