Class: Hatchet::PlainFormatter

Inherits:
Object
  • Object
show all
Includes:
BacktraceFormatter
Defined in:
lib/hatchet/plain_formatter.rb

Overview

Public: Plain formatter class. Outputs messages with just the given message.

Useful for Rails in development mode where the log messages are intended to be human readable rather than useful for grepping, etc.

Instance Attribute Summary

Attributes included from BacktraceFormatter

#backtrace_limit

Instance Method Summary collapse

Methods included from BacktraceFormatter

#backtrace, #backtrace=

Constructor Details

#initializePlainFormatter

Public: Initialize a new instance.



15
16
17
# File 'lib/hatchet/plain_formatter.rb', line 15

def initialize
  @backtrace = true
end

Instance Method Details

#format(level, context, message) ⇒ Object

Public: Returns the formatted message.

level - The severity of the log message. context - The context of the log message. message - The message provided by the log caller.

Returns messages in the format:

MESSAGE
    BACKTRACE

The backtrace is only present if the message contains an error.



32
33
34
# File 'lib/hatchet/plain_formatter.rb', line 32

def format(level, context, message)
  with_backtrace(message, message.to_s)
end