Class: CloseYourIt::LogDevice

Inherits:
Object
  • Object
show all
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

Instance Method Details

#<<(message) ⇒ Object



18
19
20
21
# File 'lib/closeyourit/log_device.rb', line 18

def <<(message)
  write("info", message, {})
  message
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, message = nil, progname = nil, &block)
  write(SEVERITY_LEVELS.fetch(severity.to_i, "info"), message || progname, {}, &block)
end

#debug(message = nil, **attributes, &block) ⇒ Object



12
# File 'lib/closeyourit/log_device.rb', line 12

def debug(message = nil, **attributes, &block) = write("debug", message, attributes, &block)

#error(message = nil, **attributes, &block) ⇒ Object



15
# File 'lib/closeyourit/log_device.rb', line 15

def error(message = nil, **attributes, &block) = write("error", message, attributes, &block)

#fatal(message = nil, **attributes, &block) ⇒ Object



16
# File 'lib/closeyourit/log_device.rb', line 16

def fatal(message = nil, **attributes, &block) = write("fatal", message, attributes, &block)

#info(message = nil, **attributes, &block) ⇒ Object



13
# File 'lib/closeyourit/log_device.rb', line 13

def info(message = nil, **attributes, &block)  = write("info", message, attributes, &block)

#warn(message = nil, **attributes, &block) ⇒ Object



14
# File 'lib/closeyourit/log_device.rb', line 14

def warn(message = nil, **attributes, &block)  = write("warning", message, attributes, &block)