Module: Splash::Loggers

Includes:
Config
Included in:
CLISplash::CLIController, CLISplash::Commands, CLISplash::Config, CLISplash::Sequences, CLISplash::Transfers, Backends::File, Daemon::Controller, Daemon::Metrics, Daemon::Orchestrator::Grammar, Daemon::Orchestrator::Scheduler, Exiter, Sequences, Transfers, Transports::Rabbitmq::Client, WebAdmin::Controller, WebAdminApp
Defined in:
lib/splash/loggers.rb,
lib/splash/loggers/cli.rb,
lib/splash/loggers/web.rb,
lib/splash/loggers/dual.rb,
lib/splash/loggers/daemon.rb

Overview

Splash Loggers module

Defined Under Namespace

Classes: BadLevel, Cli, Daemon, Dual, LoggerTemplate, Web

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, :call => :info,
:receive => :info, :error => :result, :success => :result }
@@logger =
nil

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

Instance Method Details

#change_logger(options = {}) ⇒ Object

wrapper to change logger, call get_logger with force: true

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :logger (Symbol)

    the name of the logger actually in [:cli, :daemon, :dual]



38
39
40
41
42
# File 'lib/splash/loggers.rb', line 38

def change_logger(options = {})
  level = get_logger.level
  options[:force] = true
  get_logger(options).level = level
end

#get_logger(options = {}) ⇒ SPlash::Loggers::<type>

factory for Loggers

Parameters:

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :logger (Symbol)

    the name of the logger actually in [:cli, :daemon, :dual]

  • :force (Boolean)

    to force new instance creation (Logger is class variable)

Returns:

  • (SPlash::Loggers::<type>)

    type is Cli, Dual, Daemon, Web



18
19
20
21
22
23
24
25
26
27
# File 'lib/splash/loggers.rb', line 18

def get_logger(options = {})
  logger = (get_config.loggers[:list].include? options[:logger])? options[:logger].to_s : get_config.loggers[:default].to_s
  aclass = "Splash::Loggers::#{logger.capitalize}"
  begin
    return @@logger = Kernel.const_get(aclass)::new if options[:force]
    return @@logger ||= Kernel.const_get(aclass)::new
  rescue
    splash_exit case: :configuration_error, more: "Logger specified inexistant : #{logger}"
  end
end

#get_sessionString

build a session number

Returns:

  • (String)

    Session number



31
32
33
# File 'lib/splash/loggers.rb', line 31

def get_session
  return "#{Time.now.to_i.to_s}#{rand(999)}"
end