Sha256: 89b939ff00c0168fbbe00669df14d8514a0706999a2be5255521e7ac7425bb79

Contents?: true

Size: 674 Bytes

Versions: 1

Compression:

Stored size: 674 Bytes

Contents

# frozen_string_literal: true

require "active_support/logger"

require "dphil/log_formatter"

# Namespace module definition
module Dphil
  module_function

  def logger
    @logger ||= begin
      if defined?(::Rails) && defined?(::Rails.logger)
        ::Rails.logger
      else
        file_logger = ActiveSupport::Logger.new(File.join(GEM_ROOT, "dphil.log"))
        file_logger.formatter = LogFormatter.new
        if Constants::DEBUG
          logger = ActiveSupport::Logger.new(STDERR)
          logger.formatter = file_logger.formatter
          file_logger.extend(ActiveSupport::Logger.broadcast(logger))
        end
        file_logger
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dphil-0.1.4 lib/dphil/logger.rb