Class: Notarius::Formatter
- Inherits:
-
Object
- Object
- Notarius::Formatter
- Defined in:
- lib/notarius/formatter.rb
Overview
Handles formatting of log messages. It’s compatable with Ruby’s Logger class, but has its own opinions:
-
Whitespace in the message is converted to spaces.
-
Output is truncated to 140 characters per line.
-
Timestamps are formatted as ISO 8601 in UTC.
-
Lines in call stacks are prefixed with !‘s.
-
Any of the arguments to #call can be nil.
Instance Method Summary collapse
-
#call(severity, timestamp, application, message) ⇒ String
Generates a formatted log statement.
Instance Method Details
#call(severity, timestamp, application, message) ⇒ String
Generates a formatted log statement. This is the interface Ruby’s Logger class expects.
25 26 27 28 29 30 31 32 |
# File 'lib/notarius/formatter.rb', line 25 def call severity, , application, lines = [] lines << (severity, , ) lines << format_backtrace() lines.flatten! lines.map! { |line| make_tweetable(line) } "#{lines.join("\n")}\n" end |