Skip to content

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

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.23%. Comparing base (b557fed) to head (169848a).
⚠️ Report is 22 commits behind head on master.

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


```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.

3 participants