Class Lumberjack::Template
In: lib/lumberjack/template.rb
Parent: Object

A template converts entries to strings. Templates can contain the following place holders to reference log entry values:

  • :time
  • :severity
  • :progname
  • :unit_of_work_id
  • :message

Methods

call   new  

Constants

TEMPLATE_ARGUMENT_ORDER = %w(:time :severity :progname :pid :unit_of_work_id :message).freeze
DEFAULT_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S."
MILLISECOND_FORMAT = "%03d"
MICROSECOND_FORMAT = "%06d"

Public Class methods

Create a new template from the markup. The first_line argument is used to format only the first line of a message. Additional lines will be added to the message unformatted. If you wish to format the additional lines, use the :additional_lines options to specify a template. Note that you‘ll need to provide the line separator character in this template if you want to keep the message on multiple lines.

The time will be formatted as YYYY-MM-DDTHH:MM:SSS.SSS by default. If you wish to change the format, you can specify the :time_format option which can be either a time format template as documented in +Time#strftime+ or the values +:milliseconds+ or +:microseconds+ to use the standard format with the specified precision.

Messages will have white space stripped from both ends.

Public Instance methods

Convert an entry into a string using the template.

[Validate]