Class: Polytrix::Logger
- Inherits:
-
Object
- Object
- Polytrix::Logger
- Includes:
- Logger::Severity
- Defined in:
- lib/polytrix/logger.rb
Defined Under Namespace
Classes: LogdevLogger, StdoutLogger
Instance Attribute Summary collapse
-
#logdev ⇒ IO
readonly
The log device.
Class Method Summary collapse
-
.new_logger(implementor) ⇒ Object
(test, implementor, index).
Instance Method Summary collapse
-
#:<<(: <<()) ⇒ Object
Dump one or more messages to info.
-
#add ⇒ Object
Log a message if the given severity is high enough.
-
#banner { ... } ⇒ nil, true
Log a message with severity of banner (high level).
-
#close ⇒ Object
Close the logging devices.
-
#datetime_format ⇒ String
The date format being used.
-
#datetime_format= ⇒ Object
Sets the date format being used.
-
#debug { ... } ⇒ nil, true
Log a message with severity of debug.
-
#debug? ⇒ true, false
Whether or not the current severity level allows for the printing of debug messages.
-
#error { ... } ⇒ nil, true
Log a message with severity of error.
-
#error? ⇒ true, false
Whether or not the current severity level allows for the printing of error messages.
-
#fatal { ... } ⇒ nil, true
Log a message with severity of fatal.
-
#fatal? ⇒ true, false
Whether or not the current severity level allows for the printing of fatal messages.
-
#info { ... } ⇒ nil, true
Log a message with severity of info.
-
#info? ⇒ true, false
Whether or not the current severity level allows for the printing of info messages.
-
#initialize(options = {}) ⇒ Logger
constructor
Constructs a new logger.
-
#level ⇒ Integer
The logging severity threshold.
-
#level= ⇒ Object
Sets the logging severity threshold.
-
#progname ⇒ String
Program name to include in log messages.
-
#progname= ⇒ Object
Sets the program name to include in log messages.
-
#unknown { ... } ⇒ nil, true
Log a message with severity of unknown.
-
#warn { ... } ⇒ nil, true
Log a message with severity of warn.
-
#warn? ⇒ true, false
Whether or not the current severity level allows for the printing of warn messages.
Constructor Details
#initialize(options = {}) ⇒ Logger
Constructs a new logger.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/polytrix/logger.rb', line 24 def initialize( = {}) color = [:color] @loggers = [] @loggers << @logdev = logdev_logger([:logdev]) if [:logdev] @loggers << stdout_logger([:stdout], color) if [:stdout] @loggers << stdout_logger($stdout, color) if @loggers.empty? self.progname = [:progname] || 'Polytrix' self.level = [:level] || default_log_level end |
Instance Attribute Details
#logdev ⇒ IO (readonly)
Returns the log device.
9 10 11 |
# File 'lib/polytrix/logger.rb', line 9 def logdev @logdev end |
Class Method Details
.new_logger(implementor) ⇒ Object
(test, implementor, index)
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/polytrix/logger.rb', line 36 def self.new_logger(implementor) # (test, implementor, index) name = implementor.name # instance_name(test, implementor) index = Polytrix.implementors.index(implementor) || 0 Logger.new( stdout: STDOUT, color: Color::COLORS[index % Color::COLORS.size].to_sym, logdev: File.join(Polytrix.configuration.log_root, "#{name}.log"), level: Polytrix::Util.to_logger_level(Polytrix.configuration.log_level), progname: name ) end |
Instance Method Details
#:<<(: <<()) ⇒ Object
Dump one or more messages to info.
109 |
# File 'lib/polytrix/logger.rb', line 109 delegate_to_all_loggers :<< |
#add ⇒ Object
Log a message if the given severity is high enough.
103 |
# File 'lib/polytrix/logger.rb', line 103 delegate_to_all_loggers :add |
#banner { ... } ⇒ nil, true
Log a message with severity of banner (high level).
122 |
# File 'lib/polytrix/logger.rb', line 122 delegate_to_all_loggers :banner |
#close ⇒ Object
Close the logging devices.
230 |
# File 'lib/polytrix/logger.rb', line 230 delegate_to_all_loggers :close |
#datetime_format ⇒ String
Returns the date format being used.
92 |
# File 'lib/polytrix/logger.rb', line 92 delegate_to_first_logger :datetime_format |
#datetime_format= ⇒ Object
Sets the date format being used.
98 |
# File 'lib/polytrix/logger.rb', line 98 delegate_to_all_loggers :datetime_format= |
#debug { ... } ⇒ nil, true
Log a message with severity of debug.
135 |
# File 'lib/polytrix/logger.rb', line 135 delegate_to_all_loggers :debug |
#debug? ⇒ true, false
Returns whether or not the current severity level allows for the printing of debug messages.
140 |
# File 'lib/polytrix/logger.rb', line 140 delegate_to_first_logger :debug? |
#error { ... } ⇒ nil, true
Log a message with severity of error.
171 |
# File 'lib/polytrix/logger.rb', line 171 delegate_to_all_loggers :error |
#error? ⇒ true, false
Returns whether or not the current severity level allows for the printing of error messages.
176 |
# File 'lib/polytrix/logger.rb', line 176 delegate_to_first_logger :error? |
#fatal { ... } ⇒ nil, true
Log a message with severity of fatal.
207 |
# File 'lib/polytrix/logger.rb', line 207 delegate_to_all_loggers :fatal |
#fatal? ⇒ true, false
Returns whether or not the current severity level allows for the printing of fatal messages.
212 |
# File 'lib/polytrix/logger.rb', line 212 delegate_to_first_logger :fatal? |
#info { ... } ⇒ nil, true
Log a message with severity of info.
153 |
# File 'lib/polytrix/logger.rb', line 153 delegate_to_all_loggers :info |
#info? ⇒ true, false
Returns whether or not the current severity level allows for the printing of info messages.
158 |
# File 'lib/polytrix/logger.rb', line 158 delegate_to_first_logger :info? |
#level ⇒ Integer
Returns the logging severity threshold.
72 |
# File 'lib/polytrix/logger.rb', line 72 delegate_to_first_logger :level |
#level= ⇒ Object
Sets the logging severity threshold.
78 |
# File 'lib/polytrix/logger.rb', line 78 delegate_to_all_loggers :level= |
#progname ⇒ String
Returns program name to include in log messages.
82 |
# File 'lib/polytrix/logger.rb', line 82 delegate_to_first_logger :progname |
#progname= ⇒ Object
Sets the program name to include in log messages.
88 |
# File 'lib/polytrix/logger.rb', line 88 delegate_to_all_loggers :progname= |
#unknown { ... } ⇒ nil, true
Log a message with severity of unknown.
225 |
# File 'lib/polytrix/logger.rb', line 225 delegate_to_all_loggers :unknown |
#warn { ... } ⇒ nil, true
Log a message with severity of warn.
189 |
# File 'lib/polytrix/logger.rb', line 189 delegate_to_all_loggers :warn |
#warn? ⇒ true, false
Returns whether or not the current severity level allows for the printing of warn messages.
194 |
# File 'lib/polytrix/logger.rb', line 194 delegate_to_first_logger :warn? |