Class: Utopia::Logger::CompactFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/utopia/logger/compact_formatter.rb

Overview

Provides a concise log output format.

Instance Method Summary collapse

Constructor Details

#initializeCompactFormatter

Returns a new instance of CompactFormatter.



28
29
30
# File 'lib/utopia/logger/compact_formatter.rb', line 28

def initialize
	@start = Time.now
end

Instance Method Details

#call(severity, datetime, progname, message) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/utopia/logger/compact_formatter.rb', line 38

def call(severity, datetime, progname, message)
	if progname
		"#{Rainbow(time_offset_string).bright.blue} #{Rainbow(progname).bright}: #{message}\n"
	else
		"#{Rainbow(time_offset_string).bright.blue} #{message}\n"
	end
end

#time_offset_stringObject



32
33
34
35
36
# File 'lib/utopia/logger/compact_formatter.rb', line 32

def time_offset_string
	offset = Time.now - @start
	
	"T+#{offset.round(1).to_s.ljust(5)}"
end