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: 0, shift_size: 1_048_576, formatter: nil) ⇒ File
constructor
A new instance of File.
Constructor Details
#initialize(file, shift_age: 0, shift_size: 1_048_576, formatter: nil) ⇒ File
Returns a new instance of File.
9 10 11 12 |
# File 'lib/semlogr/sinks/file.rb', line 9 def initialize(file, shift_age: 0, shift_size: 1_048_576, 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
14 15 16 17 |
# File 'lib/semlogr/sinks/file.rb', line 14 def emit(log_event) output = @formatter.format(log_event) @logdev.write(output) end |