lib/logging/layouts/parseable.rb in logging-1.8.2 vs lib/logging/layouts/parseable.rb in logging-2.0.0

- old
+ new

@@ -1,5 +1,6 @@ +require 'socket' module Logging::Layouts # Accessor for the Parseable layout. # @@ -37,10 +38,11 @@ # was issued. # 'line' Used to output the line number where the logging request # was issued. # 'method' Used to output the method name where the logging request # was issued. + # 'hostname' Used to output the hostname # 'pid' Used to output the process ID of the currently running # program. # 'millis' Used to output the number of milliseconds elapsed from # the construction of the Layout until creation of the log # event. @@ -100,10 +102,11 @@ 'level' => '::Logging::LNAMES[event.level]'.freeze, 'message' => 'format_obj(event.data)'.freeze, 'file' => 'event.file'.freeze, 'line' => 'event.line'.freeze, 'method' => 'event.method'.freeze, + 'hostname' => "'#{Socket.gethostname}'".freeze, 'pid' => 'Process.pid'.freeze, 'millis' => 'Integer((event.time-@created_at)*1000)'.freeze, 'thread_id' => 'Thread.current.object_id'.freeze, 'thread' => 'Thread.current[:name]'.freeze, 'mdc' => 'Logging::MappedDiagnosticContext.context'.freeze, @@ -178,11 +181,11 @@ # :items => %w[timestamp level logger message] # def initialize( opts = {} ) super @created_at = Time.now - @style = opts.getopt(:style, 'json').to_s.intern - self.items = opts.getopt(:items, %w[timestamp level logger message]) + @style = opts.fetch(:style, 'json').to_s.intern + self.items = opts.fetch(:items, %w[timestamp level logger message]) end attr_reader :items # call-seq: