Class: Loggr::Adapter::AbstractAdapter
- Inherits:
-
Object
- Object
- Loggr::Adapter::AbstractAdapter
- Defined in:
- lib/loggr/adapter/abstract.rb
Overview
A basically abstract base class for logger backend implementations, provides a default implementation for MDC (hash & thread local based).
Ensure to implement ‘#logger`.
Direct Known Subclasses
Instance Method Summary collapse
-
#logger(name, options = {}) ⇒ Object
Implement which creates a new instance of a logger.
-
#mdc ⇒ Object
Use a simple thread local hash as fake MDC, because it’s not supported by the logger anyway - but it should be available for consistency and usage.
Instance Method Details
#logger(name, options = {}) ⇒ Object
Implement which creates a new instance of a logger.
12 13 14 |
# File 'lib/loggr/adapter/abstract.rb', line 12 def logger(name, = {}) raise "#{self.class.name}#logger is declared `abstract': implement #logger method" end |
#mdc ⇒ Object
Use a simple thread local hash as fake MDC, because it’s not supported by the logger anyway - but it should be available for consistency and usage.
19 20 21 22 |
# File 'lib/loggr/adapter/abstract.rb', line 19 def mdc mdc_key = "#{self.class.name}.mdc" Thread.current[mdc_key] ||= Hash.new end |