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

Respect the log level configured in Mongoid logger when overriding it with Semantic Logger #193

Open
Shankar1598 opened this issue Sep 30, 2023 · 1 comment

Comments

@Shankar1598
Copy link

Shankar1598 commented Sep 30, 2023

Environment

Provide at least:

  • Ruby Version: 3.2.2 (2023-03-30 revision e51014f9c0) +YJIT [x86_64-linux]

  • Rails Version: 7.0.8

  • Semantic Logger Version: 4.14.0

  • Rails Semantic Logger Version: 4.12.0

  • Rails configuration:

config.mongoid.logger.level = Logger::INFO
config.semantic_logger.add_appender(io: $stdout, formatter: :color)

Expected Behavior

  1. The debug level logs from Mongoid.logger should not be printed in the rails console.
  2. Running Mongoid.logger.level should return :info

Actual Behavior

  1. The debug level logs from Mongoid.logger are printed in the rails console
  2. Running Mongoid.logger.level is returning :debug

Workaround

I have fixed this using the following configuration

config.after_initialize do
  Mongoid.logger.level = Logger::INFO
end

PR

The override is happening here. Should be possible to read the configured log level from Mongoid.logger and reaint the value in SemanticLogger[Mongoid].
Open to reaising a PR after verifying this. Let me know your thoughts.

@reidmorrison
Copy link
Owner

Try this config:

config.log_level = :info
config.semantic_logger.add_appender(io: $stdout, formatter: :color)

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

No branches or pull requests

2 participants