Module: Sidekiq::LoggingUtils
- Included in:
- Logger
- Defined in:
- lib/sidekiq/logger.rb
Constant Summary collapse
- LEVELS =
{ "debug" => 0, "info" => 1, "warn" => 2, "error" => 3, "fatal" => 4 }
Instance Method Summary collapse
- #level ⇒ Object
- #local_level ⇒ Object
- #local_level=(level) ⇒ Object
-
#log_at(level) ⇒ Object
Change the thread-local level for the duration of the given block.
Instance Method Details
#level ⇒ Object
61 62 63 |
# File 'lib/sidekiq/logger.rb', line 61 def level local_level || super end |
#local_level ⇒ Object
44 45 46 |
# File 'lib/sidekiq/logger.rb', line 44 def local_level Thread.current[:sidekiq_log_level] end |
#local_level=(level) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sidekiq/logger.rb', line 48 def local_level=(level) case level when Integer Thread.current[:sidekiq_log_level] = level when Symbol, String Thread.current[:sidekiq_log_level] = LEVELS[level.to_s] when nil Thread.current[:sidekiq_log_level] = nil else raise ArgumentError, "Invalid log level: #{level.inspect}" end end |
#log_at(level) ⇒ Object
Change the thread-local level for the duration of the given block.
66 67 68 69 70 71 72 |
# File 'lib/sidekiq/logger.rb', line 66 def log_at(level) old_local_level = local_level self.local_level = level yield ensure self.local_level = old_local_level end |