Class: CloseYourIt::LogDevice
- Inherits:
-
Object
- Object
- CloseYourIt::LogDevice
- Defined in:
- lib/closeyourit/log_device.rb
Overview
Oggetto Logger-compatibile esposto come CloseYourIt.logger: ogni chiamata inoltra a
CloseYourIt.log (→ ingest /logs). Usabile come logger esplicito dell'app, anche con attributes:
CloseYourIt.logger.warn("disco quasi pieno", disk: "sda1")
warn mappa sul livello warning (enum backend); supporta block e ::Logger#add per drop-in.
Constant Summary collapse
- SEVERITY_LEVELS =
Severità numeriche ::Logger → livelli CloseYourIt (UNKNOWN→fatal).
{ 0 => "debug", 1 => "info", 2 => "warning", 3 => "error", 4 => "fatal", 5 => "fatal" }.freeze
Instance Method Summary collapse
- #<<(message) ⇒ Object
-
#add(severity, message = nil, progname = nil, &block) ⇒ Object
(also: #log)
Compat con ::Logger#add(severity, message = nil, progname = nil).
- #debug(message = nil, **attributes, &block) ⇒ Object
- #error(message = nil, **attributes, &block) ⇒ Object
- #fatal(message = nil, **attributes, &block) ⇒ Object
- #info(message = nil, **attributes, &block) ⇒ Object
- #warn(message = nil, **attributes, &block) ⇒ Object
Instance Method Details
#<<(message) ⇒ Object
18 19 20 21 |
# File 'lib/closeyourit/log_device.rb', line 18 def <<() write("info", , {}) end |
#add(severity, message = nil, progname = nil, &block) ⇒ Object Also known as: log
Compat con ::Logger#add(severity, message = nil, progname = nil).
24 25 26 |
# File 'lib/closeyourit/log_device.rb', line 24 def add(severity, = nil, progname = nil, &block) write(SEVERITY_LEVELS.fetch(severity.to_i, "info"), || progname, {}, &block) end |
#debug(message = nil, **attributes, &block) ⇒ Object
12 |
# File 'lib/closeyourit/log_device.rb', line 12 def debug( = nil, **attributes, &block) = write("debug", , attributes, &block) |
#error(message = nil, **attributes, &block) ⇒ Object
15 |
# File 'lib/closeyourit/log_device.rb', line 15 def error( = nil, **attributes, &block) = write("error", , attributes, &block) |
#fatal(message = nil, **attributes, &block) ⇒ Object
16 |
# File 'lib/closeyourit/log_device.rb', line 16 def fatal( = nil, **attributes, &block) = write("fatal", , attributes, &block) |
#info(message = nil, **attributes, &block) ⇒ Object
13 |
# File 'lib/closeyourit/log_device.rb', line 13 def info( = nil, **attributes, &block) = write("info", , attributes, &block) |
#warn(message = nil, **attributes, &block) ⇒ Object
14 |
# File 'lib/closeyourit/log_device.rb', line 14 def warn( = nil, **attributes, &block) = write("warning", , attributes, &block) |