Class: Itly::Loggers
- Inherits:
-
Object
- Object
- Itly::Loggers
- Defined in:
- lib/itly/loggers.rb
Overview
Loggers class, provide default usual loggers for convenience
Class Method Summary collapse
-
.itly_dot_log ⇒ Logger
Logger to log into ‘itly.log’ file on the current directory.
-
.nil_logger ⇒ NilClass
No logger.
-
.std_out ⇒ Logger
Logger to log to standard out.
-
.vars_to_log(vars) ⇒ String
Shorthand to filter variables in a log message.
Class Method Details
.itly_dot_log ⇒ Logger
Logger to log into ‘itly.log’ file on the current directory
13 14 15 |
# File 'lib/itly/loggers.rb', line 13 def self.itly_dot_log Logger.new 'itly.log' end |
.nil_logger ⇒ NilClass
No logger
31 32 33 |
# File 'lib/itly/loggers.rb', line 31 def self.nil_logger nil end |
.std_out ⇒ Logger
Logger to log to standard out
22 23 24 |
# File 'lib/itly/loggers.rb', line 22 def self.std_out Logger.new $stdout end |
.vars_to_log(vars) ⇒ String
Shorthand to filter variables in a log message
Check if the variable has a value, and return a list for the log message
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/itly/loggers.rb', line 43 def self.vars_to_log(vars) vars.collect do |name, value| next if value.nil? if value.is_a?(Hash) || value.is_a?(Array) "#{name}: #{value}" if value.any? else "#{name}: #{value}" end end.compact.join ', ' end |