Sha256: 7f0258f1aa1e08b08138ce026306ed570b73a3f38e8dc228682ea91de5fe6349

Contents?: true

Size: 641 Bytes

Versions: 1

Compression:

Stored size: 641 Bytes

Contents

module RailsStdoutLogging
  class StdoutLogger < ::Logger
    include ::LoggerSilence if defined?(::LoggerSilence)
  end

  class Rails
    def self.heroku_stdout_logger
      logger       = StdoutLogger.new(STDOUT)
      logger       = ActiveSupport::TaggedLogging.new(logger) if defined?(ActiveSupport::TaggedLogging)
      logger.level = StdoutLogger.const_get(log_level)
      logger
    end

    def self.log_level
      ([(ENV['LOG_LEVEL'] || ::Rails.application.config.log_level).to_s.upcase, "INFO"] & %w[DEBUG INFO WARN ERROR FATAL UNKNOWN]).compact.first
    end

    def self.set_logger
      STDOUT.sync = true
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_stdout_logging-0.0.4 lib/rails_stdout_logging/rails.rb