Class: Hatchet::HipChatEmoticonFormatter
- Inherits:
-
Object
- Object
- Hatchet::HipChatEmoticonFormatter
- Includes:
- BacktraceFormatter
- Defined in:
- lib/hatchet-hipchat/hipchat_emoticon_formatter.rb
Overview
Public: Formatter that outputs messages with HipChat emoticons in place of the level.
Mapping
:debug -> (content)
:info -> (wat)
:warn -> (ohcrap)
:error -> (omg)
:fatal -> (boom)
Emoticon reference: hipchat-emoticons.heroku.com/
Constant Summary collapse
- LEVEL_EMOTICON_MAP =
Internal: Map for converting levels to emoticons.
{ :debug => '(content)', :info => '(wat)', :warn => '(ohcrap)', :error => '(omg)', :fatal => '(boom)' }
- DEFAULT_BACKTRACE_LIMIT =
Internal: The number of line to limit backtraces to by default.
4
Instance Method Summary collapse
-
#format(level, context, message) ⇒ Object
Public: Returns the formatted message with HipChat emoticons in place of the level.
-
#initialize(args = {}) ⇒ HipChatEmoticonFormatter
constructor
Public: Creates a new instance.
Constructor Details
#initialize(args = {}) ⇒ HipChatEmoticonFormatter
Public: Creates a new instance.
35 36 37 |
# File 'lib/hatchet-hipchat/hipchat_emoticon_formatter.rb', line 35 def initialize(args = {}) self.backtrace_limit = args.fetch(:backtrace_limit, DEFAULT_BACKTRACE_LIMIT) end |
Instance Method Details
#format(level, context, message) ⇒ Object
Public: Returns the formatted message with HipChat emoticons in place of the level.
level - The severity of the log message. context - The context of the log message. message - The message provided by the log caller.
Mapping
:debug -> (content)
:info -> (wat)
:warn -> (ohcrap)
:error -> (omg)
:fatal -> (boom)
Returns messages in the format:
LEVEL - CONTEXT NDC - MESSAGE
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/hatchet-hipchat/hipchat_emoticon_formatter.rb', line 58 def format(level, context, ) msg = .to_s.strip if .ndc.any? msg = "#{LEVEL_EMOTICON_MAP[level]} - #{context} #{.ndc.join(' ')} - #{msg}" else msg = "#{LEVEL_EMOTICON_MAP[level]} - #{context} - #{msg}" end with_backtrace(, msg) end |