Module: Cosmo::Logger::Context
- Defined in:
- lib/cosmo/logger.rb
Constant Summary collapse
- KEY =
:cosmo_context
Class Method Summary collapse
Class Method Details
.current ⇒ Object
24 25 26 27 |
# File 'lib/cosmo/logger.rb', line 24 def self.current Thread.current[KEY] ||= {} Thread.current[KEY] end |
.with(**options) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/cosmo/logger.rb', line 11 def self.with(**) prev = current Thread.current[KEY] = prev.merge() yield if block_given? ensure Thread.current[KEY] = prev if block_given? end |
.without(*keys) ⇒ Object
19 20 21 22 |
# File 'lib/cosmo/logger.rb', line 19 def self.without(*keys) Thread.current[KEY] = current.except(*keys) nil end |