Class: Splash::Loggers::LoggerTemplate

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

Direct Known Subclasses

Cli, Daemon, Dual

Constant Summary collapse

LEVELS =
[:debug, :warn, :info, :result, :fatal, :unknown]
ALIAS =
{:flat => :info, :item => :info, :ok => :info, :ko => :info, :trigger => :info,
:schedule => :info, :arrow => :info, :send => :info,
:receive => :info, :error => :result, :success => :result }

Constants included from Constants

Constants::AUTHOR, Constants::BACKENDS_STRUCT, Constants::CONFIG_FILE, Constants::COPYRIGHT, Constants::DAEMON_LOGMON_SCHEDULING, Constants::DAEMON_PID_FILE, Constants::DAEMON_PID_PATH, Constants::DAEMON_PROCESS_NAME, Constants::DAEMON_STDERR_TRACE, Constants::DAEMON_STDOUT_TRACE, Constants::EMAIL, Constants::EXECUTION_TEMPLATE, Constants::EXECUTION_TEMPLATE_TOKENS_LIST, Constants::LICENSE, Constants::LOGGERS_STRUCT, Constants::PROMETHEUS_PUSHGATEWAY_HOST, Constants::PROMETHEUS_PUSHGATEWAY_PORT, Constants::TRACE_PATH, Constants::TRANSPORTS_STRUCT, Constants::VERSION

Instance Method Summary collapse

Methods included from Config

#get_config

Methods included from ConfigUtilities

#checkconfig, #setupsplash

Methods included from Helpers

#daemonize, #get_process, #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

Returns a new instance of LoggerTemplate.



46
47
48
49
50
# File 'lib/splash/loggers.rb', line 46

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


end

Instance Method Details

#levelObject



61
62
63
# File 'lib/splash/loggers.rb', line 61

def level
  return @active_levels.first
end

#level=(level) ⇒ Object



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

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



53
54
55
56
57
58
# File 'lib/splash/loggers.rb', line 53

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