lib/karafka/instrumentation/logger.rb in karafka-1.2.13 vs lib/karafka/instrumentation/logger.rb in karafka-1.3.0.rc1

- old
+ new

@@ -3,31 +3,33 @@ module Karafka module Instrumentation # Default logger for Event Delegator # @note It uses ::Logger features - providing basic logging class Logger < ::Logger - include Singleton - # Map containing information about log level for given environment ENV_MAP = { 'production' => ::Logger::ERROR, 'test' => ::Logger::ERROR, 'development' => ::Logger::INFO, 'debug' => ::Logger::DEBUG, 'default' => ::Logger::INFO }.freeze + private_constant :ENV_MAP + # Creates a new instance of logger ensuring that it has a place to write to + # @param _args Any arguments that we don't care about but that are needed in order to + # make this logger compatible with the default Ruby one def initialize(*_args) ensure_dir_exists super(target) self.level = ENV_MAP[Karafka.env] || ENV_MAP['default'] end private # @return [Karafka::Helpers::MultiDelegator] multi delegator instance - # to which we will be writtng logs + # to which we will be writing logs # We use this approach to log stuff to file and to the STDOUT at the same time def target Karafka::Helpers::MultiDelegator .delegate(:write, :close) .to(STDOUT, file)