Sha256: 781c39b197a2e8aeccae5b5b99d85192312f6658a03cc98ef47b2c7cd2f76262

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

require 'observed/configurable'

module Observed
  module Logging
    include Observed::Configurable

    # !@attribute [r] logger
    #  @return [Logger]
    attribute :logger

    # @return [Boolean] `true` if a value is set for the attribute :logger
    def logging_enabled?
      has_attribute_value? :logger
    end

    # Log the debug message through the logger configured via the :logger attribute
    # @param [String] message
    def log_debug(message)
      logger.debug message if logging_enabled?
    end

    # Log the info message through the logger configured via the :logger attribute
    # @param [String] message
    def log_info(message)
      logger.info message if logging_enabled?
    end

    # Log the warn message through the logger configured via the :logger attribute
    # @param [String] message
    def log_warn(message)
      logger.warn message if logging_enabled?
    end

    # Log the error message through the logger configured via the :logger attribute
    # @param [String] message
    def log_error(message)
      logger.error message if logging_enabled?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
observed-0.2.0 lib/observed/logging.rb
observed-0.2.0.rc2 lib/observed/logging.rb
observed-0.2.0.rc1 lib/observed/logging.rb