Method: Logging.clear_diagnostic_contexts
- Defined in:
- lib/logging/diagnostic_context.rb
.clear_diagnostic_contexts(all = false) ⇒ Object
Public: Convenience method that will clear both the Mapped Diagnostic Context and the Nested Diagnostic Context of the current thread. If the ‘all` flag passed to this method is true, then the diagnostic contexts for every thread in the application will be cleared.
all - Boolean flag used to clear the context of every Thread (default is false)
Returns the Logging module.
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/logging/diagnostic_context.rb', line 397 def self.clear_diagnostic_contexts( all = false ) if all DIAGNOSTIC_MUTEX.synchronize do Thread.list.each do |t| t.thread_variable_set(MappedDiagnosticContext::NAME, nil) if t.thread_variable?(MappedDiagnosticContext::NAME) t.thread_variable_set(NestedDiagnosticContext::NAME, nil) if t.thread_variable?(NestedDiagnosticContext::NAME) t.thread_variable_set(MappedDiagnosticContext::STACK_NAME, nil) if t.thread_variable?(MappedDiagnosticContext::STACK_NAME) end end else MappedDiagnosticContext.clear NestedDiagnosticContext.clear end self end |