Sha256: c42226876a2aa495386a62f53a74fa2fb0a85935d8bbefe7033ba8ebab4df16d

Contents?: true

Size: 914 Bytes

Versions: 11

Compression:

Stored size: 914 Bytes

Contents

module Lita
  # Creates a Logger with the proper configuration.
  module Logger
    class << self
      # Creates a new {::Logger} outputting to standard error with the given
      # severity level and a custom format.
      # @param level [Symbol, String] The name of the log level to use.
      # @return [::Logger] The {::Logger} object.
      def get_logger(level, formatter = Lita.config.robot.log_formatter)
        logger = ::Logger.new(STDERR)
        logger.level = get_level_constant(level)
        logger.formatter = formatter
        logger
      end

      private

      # Gets the Logger constant for the given severity level.
      def get_level_constant(level)
        if level
          begin
            ::Logger.const_get(level.to_s.upcase)
          rescue NameError
            return ::Logger::INFO
          end
        else
          ::Logger::INFO
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
lita-4.8.0 lib/lita/logger.rb
lita-4.8.0.beta1 lib/lita/logger.rb
lita-4.7.1 lib/lita/logger.rb
lita-4.7.0 lib/lita/logger.rb
lita-4.6.1 lib/lita/logger.rb
lita-4.6.0 lib/lita/logger.rb
lita-4.5.0 lib/lita/logger.rb
lita-4.4.3 lib/lita/logger.rb
lita-4.4.2 lib/lita/logger.rb
lita-4.4.1 lib/lita/logger.rb
lita-4.4.0 lib/lita/logger.rb