Sha256: f51b1237caafac6071b8b782296e45713b5a000a28cb4bfdece12db63b3b2239
Contents?: true
Size: 785 Bytes
Versions: 6
Compression:
Stored size: 785 Bytes
Contents
# -*- ruby -*- # vim: set nosta noet ts=4 sw=4: # frozen_string_literal: true require 'time' require 'json' require 'loggability/formatter' unless defined?( Loggability::Formatter ) # Output logs as JSON. class Loggability::Formatter::Structured < Loggability::Formatter # The version of the format output LOG_FORMAT_VERSION = 1 ### Format a message of the specified +severity+ using the given +time+, ### +progname+, and +message+. 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 end # class Loggability::Formatter::Default
Version data entries
6 entries across 6 versions & 1 rubygems