Class: Padrino::GelfLogger

Inherits:
GELF::Notifier
  • Object
show all
Defined in:
lib/padrino_gelflogger/gelf_logger.rb

Constant Summary collapse

LevelMappings =
{
  fatal: 4,
  error: 3,
  warn:  2,
  info:  1,
  debug: 0,
  devel: 0
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#levelObject

Returns the value of attribute level.



3
4
5
# File 'lib/padrino_gelflogger/gelf_logger.rb', line 3

def level
  @level
end

Instance Method Details

#<<(msg) ⇒ Object



34
35
36
# File 'lib/padrino_gelflogger/gelf_logger.rb', line 34

def <<(msg)
  push(msg, level)
end

#bench(action, began_at, message, level = :debug, color = :yellow, full_message = nil) ⇒ Object



44
45
46
47
48
49
# File 'lib/padrino_gelflogger/gelf_logger.rb', line 44

def bench(action, began_at, message, level=:debug, color=:yellow, full_message=nil)
  duration = ((Time.now - began_at) * 1000).to_i
  short_message = "(%s %dms) - %s" % [ action, duration, clean(message.to_s) ]
  options = {short_message: short_message, full_message: full_message, _Duration: duration, _Action: action}
  notify_with_level(gelf_level(level), options)
end

#log(*args) ⇒ Object



28
29
# File 'lib/padrino_gelflogger/gelf_logger.rb', line 28

def log(*args)
end

#log_static(*args) ⇒ Object



31
32
# File 'lib/padrino_gelflogger/gelf_logger.rb', line 31

def log_static(*args)
end

#push(message = nil, level = nil) ⇒ Object



38
39
40
41
42
# File 'lib/padrino_gelflogger/gelf_logger.rb', line 38

def push(message = nil, level = nil)
  msg = clean(message.to_s.strip)
  return if message.empty?
  notify_with_level(gelf_level(level), msg)
end