Sha256: 6443ac9fea13a5369e7fdd360af3ca689dfd39fde527ad2300966fc23f5a0bcd

Contents?: true

Size: 760 Bytes

Versions: 1

Compression:

Stored size: 760 Bytes

Contents

# frozen_string_literal: true
require 'active_support'

module FluentLoggerRails
  class Logger < ::ActiveSupport::Logger
    def initialize(logger, path:, level:)
      @level = SEV_LABEL.index(level.to_s.upcase)
      @path = path
      @logger = logger
      after_initialize if respond_to? :after_initialize
    end

    def add(severity, message = nil, progname = nil)
      return true if severity < @level

      message = (block_given? ? yield : progname) if message.blank?
      return true if message.blank?

      message = format_message(severity, Time.now, progname, message)
      message = { message: message } unless message.is_a? Hash

      @logger.post(@path, message)
      true
    end

    def close
      @logger.close
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent_logger_rails-0.1.0 lib/fluent_logger_rails/logger.rb