Class: SemanticLogger::SyncProcessor
- Inherits:
-
Object
- Object
- SemanticLogger::SyncProcessor
- Defined in:
- lib/semantic_logger/sync_processor.rb
Overview
The SyncProcessor performs logging in the current thread.
Appenders are designed to only be used by one thread at a time, so all calls are monitor protected in case SyncProcessor is being used in a multi-threaded environment.
Class Attribute Summary collapse
-
.logger ⇒ Object
Internal logger for SemanticLogger For example when an appender is not working etc..
Instance Attribute Summary collapse
-
#appenders ⇒ Object
readonly
Returns the value of attribute appenders.
Instance Method Summary collapse
- #add(*args, &block) ⇒ Object
- #close ⇒ Object
- #flush ⇒ Object
-
#initialize(appenders = nil) ⇒ SyncProcessor
constructor
A new instance of SyncProcessor.
- #log(*args, &block) ⇒ Object
- #reopen(*args) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(appenders = nil) ⇒ SyncProcessor
Returns a new instance of SyncProcessor.
49 50 51 52 |
# File 'lib/semantic_logger/sync_processor.rb', line 49 def initialize(appenders = nil) @monitor = Monitor.new @appenders = appenders || Appenders.new(self.class.logger.dup) end |
Class Attribute Details
.logger ⇒ Object
Internal logger for SemanticLogger
For example when an appender is not working etc..
By default logs to $stderr
38 39 40 41 42 43 44 45 |
# File 'lib/semantic_logger/sync_processor.rb', line 38 def self.logger @logger ||= begin l = SemanticLogger::Appender::IO.new($stderr, level: :warn) l.name = name l end end |
Instance Attribute Details
#appenders ⇒ Object (readonly)
Returns the value of attribute appenders.
47 48 49 |
# File 'lib/semantic_logger/sync_processor.rb', line 47 def appenders @appenders end |
Instance Method Details
#add(*args, &block) ⇒ Object
7 8 9 |
# File 'lib/semantic_logger/sync_processor.rb', line 7 def add(*args, &block) @monitor.synchronize { @appenders.add(*args, &block) } end |
#close ⇒ Object
19 20 21 |
# File 'lib/semantic_logger/sync_processor.rb', line 19 def close @monitor.synchronize { @appenders.close } end |
#flush ⇒ Object
15 16 17 |
# File 'lib/semantic_logger/sync_processor.rb', line 15 def flush @monitor.synchronize { @appenders.flush } end |
#log(*args, &block) ⇒ Object
11 12 13 |
# File 'lib/semantic_logger/sync_processor.rb', line 11 def log(*args, &block) @monitor.synchronize { @appenders.log(*args, &block) } end |
#reopen(*args) ⇒ Object
23 24 25 |
# File 'lib/semantic_logger/sync_processor.rb', line 23 def reopen(*args) @monitor.synchronize { @appenders.reopen(*args) } end |
#start ⇒ Object
54 55 56 |
# File 'lib/semantic_logger/sync_processor.rb', line 54 def start # NOP end |