Class: Logdup::LogDuplication
- Inherits:
-
Object
- Object
- Logdup::LogDuplication
- Defined in:
- lib/logdup/log_duplication.rb
Instance Attribute Summary collapse
-
#async_output ⇒ Object
readonly
Returns the value of attribute async_output.
-
#buffer_size ⇒ Object
readonly
Returns the value of attribute buffer_size.
-
#device ⇒ Object
readonly
Returns the value of attribute device.
-
#logs ⇒ Object
readonly
Returns the value of attribute logs.
Instance Method Summary collapse
- #<<(message) ⇒ Object
-
#initialize(device, options = {}) ⇒ LogDuplication
constructor
A new instance of LogDuplication.
- #output ⇒ Object
Constructor Details
#initialize(device, options = {}) ⇒ LogDuplication
Returns a new instance of LogDuplication.
8 9 10 11 12 13 14 |
# File 'lib/logdup/log_duplication.rb', line 8 def initialize(device, = {}) @device = device @async_output = [:async_output] || false @buffer_size = [:buffer_size] @logs = [] @thread_id = Thread.current.object_id end |
Instance Attribute Details
#async_output ⇒ Object (readonly)
Returns the value of attribute async_output.
6 7 8 |
# File 'lib/logdup/log_duplication.rb', line 6 def async_output @async_output end |
#buffer_size ⇒ Object (readonly)
Returns the value of attribute buffer_size.
6 7 8 |
# File 'lib/logdup/log_duplication.rb', line 6 def buffer_size @buffer_size end |
#device ⇒ Object (readonly)
Returns the value of attribute device.
6 7 8 |
# File 'lib/logdup/log_duplication.rb', line 6 def device @device end |
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
6 7 8 |
# File 'lib/logdup/log_duplication.rb', line 6 def logs @logs end |
Instance Method Details
#<<(message) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/logdup/log_duplication.rb', line 16 def <<() if @thread_id == Thread.current.object_id put_first_log_if_size_over logs << end end |
#output ⇒ Object
23 24 25 |
# File 'lib/logdup/log_duplication.rb', line 23 def output @async_output ? output_async : output_sync end |