rails_semantic_logger
rails_semantic_logger copied to clipboard
Unexpected Behavior: Debug Logs returning `false` when `default_level = :info`
Environment
- Ruby Version: 3.2.2
- Semantic logger version: 4.16
- Application/framework names and versions: Rails 6.1.7.4, Puma: 5.6.9
- Rails Semantic Logger Version: 4.17.0.
- Solidus e-commerce platform
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
- This logic is part of the Solidus framework, and no issues related to this behavior have been reported in their repository.
- The problem arises because when log_level is set to info, logger.debug returns
false
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
Duplicated the issue here, as the PR to fix it will be required pushed to the semantic_logger repo