Loggability::Formatter::

Structured class

Output logs as JSON.

Constants

LOG_FORMAT_VERSION

The version of the format output

Public Instance Methods

call( severity, time, progname, message )

Format a message of the specified severity using the given time, progname, and message.

# File lib/loggability/formatter/structured.rb, line 19
def call( severity, time, progname, message )
        severity ||= 'DEBUG'
        time ||= Time.now
        entry = {
                '@version' => LOG_FORMAT_VERSION,
                '@timestamp' => time.iso8601( 3 ),
                'level' => severity,
                'progname' => progname,
                'message' => message,
        }

        return JSON.generate( entry )
end