Class: Padrino::GelfLogger
- Inherits:
-
GELF::Notifier
- Object
- GELF::Notifier
- Padrino::GelfLogger
- 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
-
#level ⇒ Object
Returns the value of attribute level.
Instance Method Summary collapse
- #<<(msg) ⇒ Object
- #bench(action, began_at, message, level = :debug, color = :yellow, full_message = nil) ⇒ Object
- #log(*args) ⇒ Object
- #log_static(*args) ⇒ Object
- #push(message = nil, level = nil) ⇒ Object
Instance Attribute Details
#level ⇒ Object
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, , level=:debug, color=:yellow, =nil) duration = ((Time.now - began_at) * 1000).to_i = "(%s %dms) - %s" % [ action, duration, clean(.to_s) ] = {short_message: , full_message: , _Duration: duration, _Action: action} notify_with_level(gelf_level(level), ) 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( = nil, level = nil) msg = clean(.to_s.strip) return if .empty? notify_with_level(gelf_level(level), msg) end |