Sha256: 478f80062cf74e8ad0936d20dd3bdbedeb9a73457b93163e6db26fa1c0043810

Contents?: true

Size: 863 Bytes

Versions: 16

Compression:

Stored size: 863 Bytes

Contents

require 'logger'

module Firehose
  # Sets up logging
  def self.logger
    @logger ||= Logger.new($stdout)
  end

  def self.logger=(logger)
    @logger = logger
  end

  self.logger.level = if ENV['LOG_LEVEL']
    Logger.const_get(ENV['LOG_LEVEL'].upcase)
  else
    case ENV['RACK_ENV']
      when 'test'         then Logger::ERROR
      when 'development'  then Logger::DEBUG
      else Logger::INFO
    end
  end

  # TODO: Provide some way to allow this to be configured via an ENV variable.
  self.logger.formatter = lambda do |severity, time, name, msg|
    out_time = time.utc.strftime "%Y-%m-%d %H:%M:%S.%L"
    "[#{out_time} ##$$] #{severity} : #{msg}\n"
  end
end

# stdout gets "lost" in Foreman if this isn't here
# https://github.com/ddollar/foreman/wiki/Missing-Output
$stdout.sync = true if ENV['RACK_ENV'] == 'development' || ENV['SYNC_LOGGING']

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
firehose-1.3.6 lib/firehose/logging.rb
firehose-1.2.20 lib/firehose/logging.rb
firehose-1.2.13 lib/firehose/logging.rb
firehose-1.2.12 lib/firehose/logging.rb
firehose-1.2.11 lib/firehose/logging.rb
firehose-1.2.10 lib/firehose/logging.rb
firehose-1.2.9 lib/firehose/logging.rb
firehose-1.2.8 lib/firehose/logging.rb
firehose-1.2.7 lib/firehose/logging.rb
firehose-1.2.6 lib/firehose/logging.rb
firehose-1.2.5 lib/firehose/logging.rb
firehose-1.2.4 lib/firehose/logging.rb
firehose-1.2.3 lib/firehose/logging.rb
firehose-1.2.2 lib/firehose/logging.rb
firehose-1.2.1 lib/firehose/logging.rb
firehose-1.2.0 lib/firehose/logging.rb