Respect the log level configured in Mongoid logger when overriding it with Semantic Logger
Shankar1598 opened this issue · 1 comments
Shankar1598 commented
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
- The debug level logs from
Mongoid.logger
should not be printed in the rails console. - Running
Mongoid.logger.level
should return:info
Actual Behavior
- The debug level logs from
Mongoid.logger
are printed in the rails console - 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 commented
Try this config:
config.log_level = :info
config.semantic_logger.add_appender(io: $stdout, formatter: :color)