Sha256: 0616d2a444e14d1c680e730f6b42b3634c11ff8fd68e6104ab33bfce718c58b2

Contents?: true

Size: 537 Bytes

Versions: 5

Compression:

Stored size: 537 Bytes

Contents

require 'logger'
require 'semlogr/formatters/text_formatter'

module Semlogr
  module Sinks
    class File
      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

      def emit(log_event)
        output = @formatter.format(log_event)
        @logdev.write(output)
      end
    end

    ComponentRegistry.register(:sink, file: File)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
semlogr-0.3.0 lib/semlogr/sinks/file.rb
semlogr-0.2.3 lib/semlogr/sinks/file.rb
semlogr-0.2.2 lib/semlogr/sinks/file.rb
semlogr-0.2.1 lib/semlogr/sinks/file.rb
semlogr-0.2.0 lib/semlogr/sinks/file.rb