Class: BrpmLogger
- Inherits:
-
LoggerBase
- Object
- LoggerBase
- BrpmLogger
- Defined in:
- lib/logging/brpm_logger.rb
Instance Attribute Summary collapse
-
#request_log_file_path ⇒ Object
readonly
Returns the value of attribute request_log_file_path.
-
#step_run_log_file_path ⇒ Object
readonly
Returns the value of attribute step_run_log_file_path.
Instance Method Summary collapse
-
#initialize ⇒ BrpmLogger
constructor
A new instance of BrpmLogger.
- #log(message) ⇒ Object
Methods inherited from LoggerBase
Constructor Details
#initialize ⇒ BrpmLogger
Returns a new instance of BrpmLogger.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/logging/brpm_logger.rb', line 7 def initialize @step_number = BrpmAuto.params.step_number @step_name = BrpmAuto.params.step_name @request_log_file_path = "#{BrpmAuto.params.automation_results_dir}/#{BrpmAuto.params.request_id}.log" # @step_run_log_file_path = "#{BrpmAuto.params.automation_results_dir}/#{BrpmAuto.params.request_id}_#{BrpmAuto.params.step_id}_#{BrpmAuto.params.run_key}.log" @step_run_log_file_path = BrpmAuto.params.output_file print "Logging to #{@step_run_log_file_path} and #{@request_log_file_path}\n" unless BrpmAuto.params.also_log_to_console end |
Instance Attribute Details
#request_log_file_path ⇒ Object (readonly)
Returns the value of attribute request_log_file_path.
4 5 6 |
# File 'lib/logging/brpm_logger.rb', line 4 def request_log_file_path @request_log_file_path end |
#step_run_log_file_path ⇒ Object (readonly)
Returns the value of attribute step_run_log_file_path.
5 6 7 |
# File 'lib/logging/brpm_logger.rb', line 5 def step_run_log_file_path @step_run_log_file_path end |
Instance Method Details
#log(message) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/logging/brpm_logger.rb', line 19 def log() = .to_s # in case booleans or whatever are passed = "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}" = "" prefix = "#{timestamp}|#{'%2.2s' % @step_number}|#{'%-20.20s' % @step_name}|" .gsub!("\n", "\n" + (" " * prefix.length)) = "#{prefix}#{message}\n" File.open(@request_log_file_path, "a") do |log_file| log_file.print() end File.open(@step_run_log_file_path, "a") do |log_file| log_file.print() end print() if BrpmAuto.params.also_log_to_console end |