Class: Ecoportal::API::Logger
- Inherits:
-
Object
- Object
- Ecoportal::API::Logger
- Defined in:
- lib/ecoportal/api/logger.rb
Constant Summary collapse
- TIMESTAMP_PATTERN =
"%Y-%m-%dT%H:%M:%S".freeze
- STDOUT_FORMAT_PROC =
proc do |severity, _datetime, _progname, msg| prefix = "%5s > " % severity # rubocop:disable Style/FormatString msg.lines.map.with_index do |line, idx| if idx.zero? prefix + line.chomp else (" " * prefix.length) + line.chomp end end.join("\n")+"\n" end
- FILE_FORMAT_PROC =
proc do |severity, datetime, _progname, msg| prefix = "%5s(%s) > " % [severity, datetime.strftime(TIMESTAMP_PATTERN)] # rubocop:disable Style/FormatString, Style/FormatStringToken msg.lines.map.with_index do |line, idx| if idx.zero? prefix + line.chomp else (" " * prefix.length) + line.chomp end end.join("\n")+"\n" end
Instance Attribute Summary collapse
-
#console ⇒ Object
readonly
Returns the value of attribute console.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize(console_level: ::Logger::INFO, file_level: ::Logger::DEBUG, output_file: File.join(Dir.getwd, "API_Log-#{Time.now.strftime("%Y-%m-%dT%H%M")}.txt")) ⇒ Logger
constructor
A new instance of Logger.
Constructor Details
#initialize(console_level: ::Logger::INFO, file_level: ::Logger::DEBUG, output_file: File.join(Dir.getwd, "API_Log-#{Time.now.strftime("%Y-%m-%dT%H%M")}.txt")) ⇒ Logger
Returns a new instance of Logger.
30 31 32 33 34 35 36 37 |
# File 'lib/ecoportal/api/logger.rb', line 30 def initialize( console_level: ::Logger::INFO, file_level: ::Logger::DEBUG, output_file: File.join(Dir.getwd, "API_Log-#{Time.now.strftime("%Y-%m-%dT%H%M")}.txt") ) @console = make_stdout_logger(console_level) @file = make_file_logger(file_level, output_file) end |
Instance Attribute Details
#console ⇒ Object (readonly)
Returns the value of attribute console.
28 29 30 |
# File 'lib/ecoportal/api/logger.rb', line 28 def console @console end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
28 29 30 |
# File 'lib/ecoportal/api/logger.rb', line 28 def file @file end |