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

Fix log files and remove env_logger #511

Merged
merged 2 commits into from
Dec 1, 2021
Merged

Conversation

yihuaf
Copy link
Collaborator

@yihuaf yihuaf commented Dec 1, 2021

Fix #475

As mentioned in #475, the log file is broken due to env_logger breaks. Originally we were hoping using env_logger can save us from maintaining our own logger, but it seems that env_logger is not a good fit. While there is an issue filed with env_logger to fix file logging target, it is unlikely to be fixed in a reasonable time frame.

For logger, we require:

  1. Log to file
  2. Ability to set formatter for JSON
  3. Not complex to configure and lightweight since our use case is simple and we would like to maintain performance.

For now, let's fall back to use our own logger implementation. It is simple enough and fits our use case. I am surprised that there is no good out of box logger for Rust similar to logrus for Golang. Most of the logging libraries in Rust either lacks features or is not well maintained. https://github.com/tokio-rs/tracing seems to be a promising substitute for log in rust, but it requires more work.

remove env_logger and use our own logger
@yihuaf yihuaf requested a review from utam0k December 1, 2021 04:46
@codecov-commenter
Copy link

Codecov Report

Merging #511 (300b396) into main (6cb39e1) will increase coverage by 0.38%.
The diff coverage is 70.83%.

@@            Coverage Diff             @@
##             main     #511      +/-   ##
==========================================
+ Coverage   60.54%   60.92%   +0.38%     
==========================================
  Files          86       86              
  Lines       12604    12651      +47     
==========================================
+ Hits         7631     7708      +77     
+ Misses       4973     4943      -30     

Comment on lines +78 to +79
/// Indicates level up to which logs are to be printed
level: Option<log::Level>,
Copy link
Member

Choose a reason for hiding this comment

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

What is the case of None?

Copy link
Collaborator

Choose a reason for hiding this comment

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

None means logging is disabled. None is returned by to_level if a logging level of 'Off' is specified.

Copy link
Member

Choose a reason for hiding this comment

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

I forgot about it! You're right.

@Furisto
Copy link
Collaborator

Furisto commented Dec 1, 2021

Looks good!

@utam0k utam0k merged commit bf9a22c into youki-dev:main Dec 1, 2021
@yihuaf yihuaf deleted the yihuaf/log branch December 1, 2021 23:15
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.

Flag --log is broken?
4 participants