Module: Hooks::Core::LogContext
- Defined in:
- lib/hooks/core/logger_factory.rb
Overview
Helper for setting request context in logs
Class Method Summary collapse
-
.clear ⇒ Object
Clear request context for current thread.
-
.set(context) ⇒ Object
Set request context for current thread.
-
.with(context) { ... } ⇒ Object
Execute block with request context.
Class Method Details
.clear ⇒ Object
Clear request context for current thread
82 83 84 |
# File 'lib/hooks/core/logger_factory.rb', line 82 def self.clear Thread.current[:hooks_request_context] = nil end |
.set(context) ⇒ Object
Set request context for current thread
77 78 79 |
# File 'lib/hooks/core/logger_factory.rb', line 77 def self.set(context) Thread.current[:hooks_request_context] = context end |
.with(context) { ... } ⇒ Object
Execute block with request context
90 91 92 93 94 95 96 |
# File 'lib/hooks/core/logger_factory.rb', line 90 def self.with(context) old_context = Thread.current[:hooks_request_context] Thread.current[:hooks_request_context] = context yield ensure Thread.current[:hooks_request_context] = old_context end |