Sha256: 55930a23daf62adb0c22a645eb9bd7f01aa1c4cb7674c653b3880197b6b49928

Contents?: true

Size: 900 Bytes

Versions: 11

Compression:

Stored size: 900 Bytes

Contents

# Sets up logging

require 'logger'

module Firehose
  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

EM::Hiredis.logger = Firehose.logger

# 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

11 entries across 11 versions & 1 rubygems

Version Path
firehose-1.1.1 lib/firehose/logging.rb
firehose-1.1.0 lib/firehose/logging.rb
firehose-1.0.0 lib/firehose/logging.rb
firehose-0.2.alpha.10 lib/firehose/logging.rb
firehose-0.2.alpha.9 lib/firehose/logging.rb
firehose-0.2.alpha.8 lib/firehose/logging.rb
firehose-0.2.alpha.7 lib/firehose/logging.rb
firehose-0.2.alpha.6 lib/firehose/logging.rb
firehose-0.2.alpha.5 lib/firehose/logging.rb
firehose-0.2.alpha.3 lib/firehose/logging.rb
firehose-0.2.alpha.2 lib/firehose/logging.rb