Class: Utopia::Logger::CompactFormatter

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

Instance Method Summary collapse

Constructor Details

#initializeCompactFormatter

Returns a new instance of CompactFormatter.



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

def initialize
	@start = Time.now
end

Instance Method Details

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



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

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



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

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