module Dry::System::Plugins::Logging
Public Class Methods
extended(system)
click to toggle source
@api private
Calls superclass method
# File lib/dry/system/plugins/logging.rb, line 10 def self.extended(system) system.before(:configure) do setting :logger, reader: true setting :log_dir, default: "log" setting :log_levels, default: { development: Logger::DEBUG, test: Logger::DEBUG, production: Logger::ERROR } setting :logger_class, default: ::Logger, reader: true end system.after(:configure, &:register_logger) super end
Public Instance Methods
log_dir_path()
click to toggle source
@api private
# File lib/dry/system/plugins/logging.rb, line 57 def log_dir_path root.join(config.log_dir).realpath end
log_file_name()
click to toggle source
@api private
# File lib/dry/system/plugins/logging.rb, line 67 def log_file_name "#{config.env}.log" end
log_file_path()
click to toggle source
@api private
# File lib/dry/system/plugins/logging.rb, line 62 def log_file_path log_dir_path.join(log_file_name) end
log_level()
click to toggle source
@api private
# File lib/dry/system/plugins/logging.rb, line 52 def log_level config.log_levels.fetch(config.env, Logger::ERROR) end
register_logger()
click to toggle source
Set a logger
This is invoked automatically when a container is being configured
@return [self]
@api private
# File lib/dry/system/plugins/logging.rb, line 37 def register_logger if registered?(:logger) self elsif config.logger register(:logger, config.logger) else config.logger = logger = config.logger_class.new(log_file_path) config.logger.level = log_level register(:logger, config.logger) self end end