reidmorrison / rails_semantic_logger

Rails Semantic Logger replaces the Rails default logger with Semantic Logger
https://logger.rocketjob.io/rails
Apache License 2.0
338 stars 124 forks source link

Unexpected Behavior: Debug Logs returning `false` when `default_level = :info` #253

Open gugaiz opened 1 week ago

gugaiz commented 1 week ago

Environment

Description

I encountered an issue while using rails_semantic_logger in a Rails project with the Solidus framework. When SemanticLogger.default_level = :info or config.log_level = :info is set, debug-level logs return false, which leads to unexpected behavior.

Here’s a simplified example of the issue:

order = Spree::Order.first
order.logger.debug "Testing" # This output `false` while the original behavior is to return `true` even if log level is set to :info

This behavior affects the Solidus gem's state_machine logic, where debug logs are used in transition callbacks. For example:

after_transition do |order, transition|
  order.logger.debug "Order #{order.number} transitioned from #{transition.from} to #{transition.to} via #{transition.event}"
end

You can see this code in context here

When logs are set to :info, the state_machine process fails silently.

Context

Expected Behavior

Even when default_level or config.log_level is set to :info, calls to logger.debug should return true as it happens with the original ActiveSupport::Logger

gugaiz commented 1 week ago

Duplicated the issue here, as the PR to fix it will be required pushed to the semantic_logger repo