Class: Semlogr::Sinks::File
- Inherits:
-
Object
- Object
- Semlogr::Sinks::File
- Defined in:
- lib/semlogr/sinks/file.rb
Instance Method Summary collapse
- #emit(log_event) ⇒ Object
-
#initialize(file, shift_age: nil, shift_size: nil, formatter: nil) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(file, shift_age: nil, shift_size: nil, formatter: nil) ⇒ File
Returns a new instance of File.
6 7 8 9 |
# File 'lib/semlogr/sinks/file.rb', line 6 def initialize(file, shift_age: nil, shift_size: nil, formatter: nil) @logdev = ::Logger::LogDevice.new(file, shift_age: shift_age, shift_size: shift_size) @formatter = formatter || Formatters::TextFormatter.new end |
Instance Method Details
#emit(log_event) ⇒ Object
11 12 13 14 |
# File 'lib/semlogr/sinks/file.rb', line 11 def emit(log_event) output = @formatter.format(log_event) @logdev.write(output) end |