Sha256: 22efa3ef4ecc1470a5098d7b29ae032a2c7381359d31c062e78c3496ac90b10b

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

module Ougai
  # A logger created by the `child` method of parent logger
  class ChildLogger
    include Logging

    # @private
    def initialize(parent, fields)
      @parent = parent
      @with_fields = fields
    end

    def level
      @parent.level
    end

    # Whether the current severity level allows for logging DEBUG.
    # @return [Boolean] true if allows
    def debug?
      @parent.debug?
    end

    # Whether the current severity level allows for logging INFO.
    # @return [Boolean] true if allows
    def info?
      @parent.info?
    end

    # Whether the current severity level allows for logging WARN.
    # @return [Boolean] true if allows
    def warn?
      @parent.warn?
    end

    # Whether the current severity level allows for logging ERROR.
    # @return [Boolean] true if allows
    def error?
      @parent.error?
    end

    # Whether the current severity level allows for logging FATAL.
    # @return [Boolean] true if allows
    def fatal?
      @parent.fatal?
    end

    # @private
    def chain(severity, args, fields, hooks)
      hooks.push(@before_log) if @before_log
      @parent.chain(severity, args, weak_merge!(fields, @with_fields), hooks)
    end

    protected

    def append(severity, args)
      hooks = @before_log ? [@before_log] : []
      @parent.chain(severity, args, @with_fields.dup, hooks)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ougai-1.6.6 lib/ougai/child_logger.rb
ougai-1.6.5 lib/ougai/child_logger.rb
ougai-1.6.4 lib/ougai/child_logger.rb
ougai-1.6.3 lib/ougai/child_logger.rb
ougai-1.6.1 lib/ougai/child_logger.rb
ougai-1.5.8 lib/ougai/child_logger.rb
ougai-1.5.7 lib/ougai/child_logger.rb
ougai-1.5.6 lib/ougai/child_logger.rb