Class: Log4j2LoggerBridge::Destination::Configuration
- Inherits:
-
Object
- Object
- Log4j2LoggerBridge::Destination::Configuration
- Includes:
- Constants
- Defined in:
- lib/log4j2_logger_bridge/destination.rb
Overview
The Configuration class for the Destination module
Constant Summary
Constants included from Constants
Constants::DEFAULT_APP_NAME, Constants::DEFAULT_LOGS_DIR_NAME, Constants::DEFAULT_LOG_PATTERN, Constants::DEFAULT_ROLLOVER_SCHEDULE, Constants::DEFAULT_ROLLOVER_SIZE, Constants::DEFAULT_RUBY_LOG_FORMAT, Constants::DEFAULT_TIMESTAMP_FORMAT, Constants::EMPTY_STRING, Constants::NUMERIC_TO_SYMBOL, Constants::SYMBOL_TO_RUBY
Instance Attribute Summary collapse
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#log_file_name ⇒ Object
Returns the value of attribute log_file_name.
-
#logs_dir_name ⇒ Object
Returns the value of attribute logs_dir_name.
-
#project_dir_path ⇒ Object
Returns the value of attribute project_dir_path.
-
#rolling_file_name_template ⇒ Object
Returns the value of attribute rolling_file_name_template.
-
#rollover_schedule ⇒ Object
Returns the value of attribute rollover_schedule.
-
#rollover_size ⇒ Object
Returns the value of attribute rollover_size.
-
#timestamp_format ⇒ Object
Returns the value of attribute timestamp_format.
Instance Method Summary collapse
- #ensure_paths! ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #log_file_path ⇒ Object
- #logs_dir_path ⇒ Object
- #resolved_rolling_file_name_template ⇒ Object
- #rollover ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 22 def initialize @project_dir_path = Dir.pwd @app_name = File.basename(@project_dir_path.to_s) @logs_dir_name = DEFAULT_LOGS_DIR_NAME @log_file_name = "#{@app_name}.log" @timestamp_format = DEFAULT_TIMESTAMP_FORMAT @rollover_schedule = DEFAULT_ROLLOVER_SCHEDULE @rollover_size = DEFAULT_ROLLOVER_SIZE @rolling_file_name_template = nil end |
Instance Attribute Details
#app_name ⇒ Object
Returns the value of attribute app_name.
18 19 20 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 18 def app_name @app_name end |
#log_file_name ⇒ Object
Returns the value of attribute log_file_name.
18 19 20 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 18 def log_file_name @log_file_name end |
#logs_dir_name ⇒ Object
Returns the value of attribute logs_dir_name.
18 19 20 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 18 def logs_dir_name @logs_dir_name end |
#project_dir_path ⇒ Object
Returns the value of attribute project_dir_path.
18 19 20 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 18 def project_dir_path @project_dir_path end |
#rolling_file_name_template ⇒ Object
Returns the value of attribute rolling_file_name_template.
18 19 20 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 18 def rolling_file_name_template @rolling_file_name_template end |
#rollover_schedule ⇒ Object
Returns the value of attribute rollover_schedule.
18 19 20 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 18 def rollover_schedule @rollover_schedule end |
#rollover_size ⇒ Object
Returns the value of attribute rollover_size.
18 19 20 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 18 def rollover_size @rollover_size end |
#timestamp_format ⇒ Object
Returns the value of attribute timestamp_format.
18 19 20 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 18 def @timestamp_format end |
Instance Method Details
#ensure_paths! ⇒ Object
50 51 52 53 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 50 def ensure_paths! FileUtils.mkdir_p(logs_dir_path) FileUtils.touch(log_file_path) end |
#log_file_path ⇒ Object
37 38 39 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 37 def log_file_path File.(File.join(logs_dir_path, log_file_name)) end |
#logs_dir_path ⇒ Object
33 34 35 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 33 def logs_dir_path File.(File.join(project_dir_path, logs_dir_name)) end |
#resolved_rolling_file_name_template ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 41 def resolved_rolling_file_name_template template = rolling_file_name_template return File.(template) if template && !template.strip.empty? File.( File.join(logs_dir_path, "#{app_name}-%d{yyyy-MM-dd}.log.gz") ) end |
#rollover ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/log4j2_logger_bridge/destination.rb', line 55 def rollover { schedule: rollover_schedule, size: rollover_size, file_pattern: resolved_rolling_file_name_template } end |