Module: Dry::System::Plugins::Logging
- Defined in:
- lib/dry/system/plugins/logging.rb
Class Method Summary collapse
- .extended(system) ⇒ Object private
Instance Method Summary collapse
- #log_dir_path ⇒ Object private
- #log_file_name ⇒ Object private
- #log_file_path ⇒ Object private
- #log_level ⇒ Object private
-
#register_logger ⇒ self
private
Set a logger.
Class Method Details
.extended(system) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dry/system/plugins/logging.rb', line 10 def self.extended(system) system.instance_eval 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 |
Instance Method Details
#log_dir_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
57 58 59 |
# File 'lib/dry/system/plugins/logging.rb', line 57 def log_dir_path root.join(config.log_dir).realpath end |
#log_file_name ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
67 68 69 |
# File 'lib/dry/system/plugins/logging.rb', line 67 def log_file_name "#{config.env}.log" end |
#log_file_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
62 63 64 |
# File 'lib/dry/system/plugins/logging.rb', line 62 def log_file_path log_dir_path.join(log_file_name) end |
#log_level ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
52 53 54 |
# File 'lib/dry/system/plugins/logging.rb', line 52 def log_level config.log_levels.fetch(config.env, Logger::ERROR) end |
#register_logger ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Set a logger
This is invoked automatically when a container is being configured
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# 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 = config.logger_class.new(log_file_path) config.logger.level = log_level register(:logger, config.logger) self end end |