Class: Splash::Loggers::Cli
- Inherits:
-
LoggerTemplate
- Object
- LoggerTemplate
- Splash::Loggers::Cli
- Defined in:
- lib/splash/loggers/cli.rb
Overview
Cli specific logger
Constant Summary collapse
- EMOJI =
mapping of UTf-8 emoji for log levels or alias
{ :unknown => "\u{1F4A5}", :fatal => "\u{26D4}", :error => "\u{1F6AB}", :ko => "\u{1F44E}", :warn => "\u{26A0}", :info => "\u{2139}", :item => " \u{1F539}", :arrow => " \u{27A1}", :schedule => "\u{23F1}", :trigger => "\u{23F0}", :send => "\u{1F4E4}", :receive => "\u{1F4E5}", :ok => "\u{1F44D}", :success => "\u{1F4AA}", :debug => "\u{1F41B}"}
- COLORS =
mapping of colors for log levels or alias
{ :unknown => :red, :fatal => :red, :error => :red, :ko => :yellow, :warn => :yellow, :item => :white, :arrow => :white, :send => :white, :schedule => :white, :trigger => :white, :receive => :white, :info => :cyan, :ok => :green, :success => :green, :debug => :magenta}
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
-
#color=(status) ⇒ Object
setter in configuration for color display.
-
#emoji=(status) ⇒ Object
setter in configuration for emoji display.
-
#log(options) ⇒ Object
log wrapper display formatted string to STDOUT.
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
Methods included from Config
Methods included from ConfigUtilities
#addservice, #checkconfig, #flush_backend, #setupsplash
Methods inherited from LoggerTemplate
Constructor Details
This class inherits a constructor from Splash::Loggers::LoggerTemplate
Instance Method Details
#color=(status) ⇒ Object
setter in configuration for color display
82 83 84 |
# File 'lib/splash/loggers/cli.rb', line 82 def color=(status) get_config.loggers[:cli][:color] = status end |
#emoji=(status) ⇒ Object
setter in configuration for emoji display
76 77 78 |
# File 'lib/splash/loggers/cli.rb', line 76 def emoji=(status) get_config.loggers[:cli][:emoji] = status end |
#log(options) ⇒ Object
log wrapper display formatted string to STDOUT
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/splash/loggers/cli.rb', line 55 def log() level = (ALIAS.keys.include? [:level])? ALIAS[[:level]] : [:level] if @active_levels.include? level then if [:level] == :flat then puts [:message] else String.disable_colorization = !get_config.loggers[:cli][:color] emoji = get_config.loggers[:cli][:emoji] emoji = check_unicode_term if emoji if emoji then display = "#{EMOJI[[:level]]} #{[:message]}" else display = "#{alt([:level])} #{[:message]}" end puts display.colorize(COLORS[[:level]]) end end end |