class Itly::Loggers

Loggers class, provide default usual loggers for convenience

Public Class Methods

itly_dot_log() click to toggle source

Logger to log into 'itly.log' file on the current directory

@return [Logger] the logger

# File lib/itly/loggers.rb, line 13
def self.itly_dot_log
  Logger.new 'itly.log'
end
nil_logger() click to toggle source

No logger

@return [NilClass] nothing

# File lib/itly/loggers.rb, line 31
def self.nil_logger
  nil
end
std_out() click to toggle source

Logger to log to standard out

@return [Logger] the logger

# File lib/itly/loggers.rb, line 22
def self.std_out
  Logger.new $stdout
end
vars_to_log(vars) click to toggle source

Shorthand to filter variables in a log message

Check if the variable has a value, and return a list for the log message

@param [Hash] vars: list of variables @return [String] log message

# 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