Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
gugaiz opened this issue Nov 27, 2024 · 1 comment
Open

Comments

@gugaiz
Copy link

gugaiz commented Nov 27, 2024

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

@gugaiz
Copy link
Author

gugaiz commented Nov 28, 2024

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant