Class: Loggr::SLF4J::MDCWrapper
- Inherits:
-
Object
- Object
- Loggr::SLF4J::MDCWrapper
- Defined in:
- lib/loggr/slf4j/mdc.rb
Overview
Wrapper around the SLF4J MDC.
Instance Attribute Summary collapse
-
#java_mdc ⇒ Object
Access the original SLF4J MDC.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Read a key from the MDC.
-
#[]=(key, value) ⇒ Object
Write a value to the MDC.
-
#clear ⇒ Object
Clear all keys from the MDC.
-
#delete(key) ⇒ Object
Remove a key from the MDC.
-
#initialize(impl = Java::OrgSlf4j::MDC) ⇒ MDCWrapper
constructor
Create a new SLF4J MDC with the supplied implementation.
-
#to_hash ⇒ Object
Convert MDC to a real hash.
Constructor Details
#initialize(impl = Java::OrgSlf4j::MDC) ⇒ MDCWrapper
Create a new SLF4J MDC with the supplied implementation.
12 13 14 |
# File 'lib/loggr/slf4j/mdc.rb', line 12 def initialize(impl = Java::OrgSlf4j::MDC) @java_mdc = impl end |
Instance Attribute Details
#java_mdc ⇒ Object
Access the original SLF4J MDC
9 10 11 |
# File 'lib/loggr/slf4j/mdc.rb', line 9 def java_mdc @java_mdc end |
Instance Method Details
#[](key) ⇒ Object
Read a key from the MDC.
17 |
# File 'lib/loggr/slf4j/mdc.rb', line 17 def [](key); java_mdc.get(key.to_s) end |
#[]=(key, value) ⇒ Object
Write a value to the MDC.
20 |
# File 'lib/loggr/slf4j/mdc.rb', line 20 def []=(key, value); java_mdc.put(key.to_s, value.to_s) end |
#clear ⇒ Object
Clear all keys from the MDC.
26 |
# File 'lib/loggr/slf4j/mdc.rb', line 26 def clear; java_mdc.clear() end |
#delete(key) ⇒ Object
Remove a key from the MDC.
23 |
# File 'lib/loggr/slf4j/mdc.rb', line 23 def delete(key); java_mdc.remove(key.to_s) end |
#to_hash ⇒ Object
Convert MDC to a real hash.
29 |
# File 'lib/loggr/slf4j/mdc.rb', line 29 def to_hash; java_mdc.getCopyOfContextMap().freeze end |