Class: Splash::Loggers::LoggerTemplate

Inherits:
Object
  • Object
show all
Includes:
Config
Defined in:
lib/splash/loggers.rb

Overview

class template for loggers

Direct Known Subclasses

Cli, Daemon, Web

Constant Summary

Constants included from Constants

Constants::AUTHOR, Constants::BACKENDS_STRUCT, Constants::CONFIG_FILE, Constants::COPYRIGHT, Constants::DAEMON_LOGMON_SCHEDULING, Constants::DAEMON_METRICS_SCHEDULING, Constants::DAEMON_PID_FILE, Constants::DAEMON_PROCESS_NAME, Constants::DAEMON_PROCMON_SCHEDULING, Constants::DAEMON_STDERR_TRACE, Constants::DAEMON_STDOUT_TRACE, Constants::DEFAULT_RETENTION, Constants::EMAIL, Constants::EXECUTION_TEMPLATE, Constants::EXECUTION_TEMPLATE_TOKENS_LIST, Constants::LICENSE, Constants::LOGGERS_STRUCT, Constants::PID_PATH, Constants::PROMETHEUS_ALERTMANAGER_URL, Constants::PROMETHEUS_PUSHGATEWAY_URL, Constants::PROMETHEUS_URL, Constants::TRACE_PATH, Constants::TRANSPORTS_STRUCT, Constants::VERSION, Constants::WEBADMIN_IP, Constants::WEBADMIN_PID_FILE, Constants::WEBADMIN_PID_PATH, Constants::WEBADMIN_PORT, Constants::WEBADMIN_PROCESS_NAME, Constants::WEBADMIN_PROXY, Constants::WEBADMIN_STDERR_TRACE, Constants::WEBADMIN_STDOUT_TRACE

Instance Method Summary collapse

Methods included from Config

#get_config, #rehash_config

Methods included from ConfigUtilities

#addservice, #checkconfig, #flush_backend, #setupsplash

Methods included from Helpers

#check_unicode_term, #daemonize, #format_by_extensions, #format_response, #get_processes, #group_root, #install_file, #is_root?, #make_folder, #make_link, #run_as_root, #search_file_in_gem, #user_root, #verify_file, #verify_folder, #verify_link, #verify_service

Constructor Details

#initializeLoggerTemplate

constructor



66
67
68
69
70
# File 'lib/splash/loggers.rb', line 66

def initialize
  self.level = get_config.loggers[:level]


end

Instance Method Details

#levelSymbol

getter for the current level

Returns:

  • (Symbol)

    level



85
86
87
# File 'lib/splash/loggers.rb', line 85

def level
  return @active_levels.first
end

#level=(level) ⇒ Object

virtual setter for level, set the current level

Parameters:

  • level (Symbol)

Raises:

  • a badLevel in case of bad level



92
93
94
95
96
97
98
99
# File 'lib/splash/loggers.rb', line 92

def level=(level)
  if LEVELS.include? level then
    @active_levels = LEVELS.dup
    @active_levels.shift(LEVELS.index(level))
  else
    raise BadLevel
  end
end

#log(options) ⇒ Object

abstract method for log wrapper

Parameters:

  • options (Hash)

Options Hash (options):

  • :level, (Symbol)

    a valid level in LEVELS or ALIAS

  • :message (String)

    text



76
77
78
79
80
81
# File 'lib/splash/loggers.rb', line 76

def log(options)
  level = (ALIAS.keys.include? options[:level])?  ALIAS[options[:level]] : options[:level]
  if @active_levels.include? level then
    puts options[:message]
  end
end