lib/franz/logger.rb in franz-1.5.5 vs lib/franz/logger.rb in franz-1.5.6
- old
+ new
@@ -1,11 +1,14 @@
+require 'socket'
require 'logger'
require 'time'
require 'colorize'
+
module Franz
+ HOSTNAME = Socket.gethostname
# Extending the Logger with TRACE capabilities
class ::Logger
SEV_LABEL << 'TRACE'
TRACE = SEV_LABEL.index('TRACE') # N.B. TRACE is above other levels
@@ -43,17 +46,20 @@
end
private
def format colorize
self.formatter = proc do |severity, datetime, _, message|
+ severity.downcase!
message = { message: message } unless message.is_a? Hash
event = {
- severity: severity.downcase!,
- timestamp: datetime.iso8601(6),
- marker: File::basename(caller[4])
- }.merge(message)
+ type: :franz,
+ level: severity,
+ '@timestamp' => datetime.iso8601(3),
+ marker: File::basename(caller[4]),
+ host: HOSTNAME
+ }.merge message
if colorize # console output
event = JSON::pretty_generate(event) + "\n"
event.colorize \
color: SEVERITY_COLORS[severity][0],
\ No newline at end of file