Sha256: 1a697f3cd52868b99ad46b5417ab9afbfdb3968ac6dbb9661bdd309a66dcc9e8

Contents?: true

Size: 817 Bytes

Versions: 2

Compression:

Stored size: 817 Bytes

Contents

require 'active_support/core_ext/module/attribute_accessors'
require 'madvertise/ext/environment'
require 'madvertise-logging'

include Madvertise::Logging

##
# The {Logging} module provides a global container for the logger object.
#
module Logging
  mattr_accessor :logger
  self.logger = nil

  # @private
  def self.create_logger
    if Env.prod?
      ImprovedLogger.new(:syslog, $0)
    else
      ImprovedLogger.new(STDERR, $0)
    end.tap do |logger|
      logger.level = :info
    end
  end

  ##
  # The {Logging::Helpers} module can be included in classes that wish to use
  # the global logger.
  #
  module Helpers

    # Retreive and possibly create the global logger object.
    #
    # @return [Logger]  The logger object.
    def log
      Logging.logger ||= Logging.create_logger
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
madvertise-ext-0.1.1 lib/madvertise/ext/logging.rb
madvertise-ext-0.1.0 lib/madvertise/ext/logging.rb