Sha256: 012d773263ad4bed3684f3d0752805bef9a1e83b8cd458604add1253a3dbe280

Contents?: true

Size: 759 Bytes

Versions: 2

Compression:

Stored size: 759 Bytes

Contents

# frozen_string_literal: true

require 'rails_autoscale_agent/config'

module RailsAutoscaleAgent
  module Logger
    def logger
      @logger ||= Config.instance.logger.tap do |logger|
        logger.extend(FakeTaggedLogging) unless logger.respond_to?(:tagged)
        logger.extend(ConditionalDebugLogging)
      end
    end

    module FakeTaggedLogging
      def tagged(*tags)
        # NOTE: Quack like ActiveSupport::TaggedLogging, but don't reimplement
        yield self
      end
    end

    module ConditionalDebugLogging
      def debug(*args)
        # Rails logger defaults to DEBUG level in production, but I don't want
        # to be chatty by default.
        super if ENV['RAILS_AUTOSCALE_LOG_LEVEL'] == 'DEBUG'
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails_autoscale_agent-0.6.1 lib/rails_autoscale_agent/logger.rb
rails_autoscale_agent-0.6.0 lib/rails_autoscale_agent/logger.rb