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"- STDOUT_FORMAT_PROC =
proc do |severity, datetime, progname, msg| prefix = "%5s > " % severity 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)] 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.
28 29 30 31 32 33 34 35 |
# File 'lib/ecoportal/api/logger.rb', line 28 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.
26 27 28 |
# File 'lib/ecoportal/api/logger.rb', line 26 def console @console end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
26 27 28 |
# File 'lib/ecoportal/api/logger.rb', line 26 def file @file end |