Class: Semlogger::Printer

Inherits:
Output show all
Defined in:
lib/semlogger/writer.rb

Instance Method Summary collapse

Constructor Details

#initialize(logdev = nil) ⇒ Printer

Returns a new instance of Printer.



19
20
21
22
# File 'lib/semlogger/writer.rb', line 19

def initialize logdev = nil
	@logdev = logdev || $stdout
	@last_reqid = nil
end

Instance Method Details

#add(severity, time, progname, data, tags, message) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/semlogger/writer.rb', line 24

def add severity, time, progname, data, tags, message
	line = case message[0]
		when :exception
			ex = message[1]
			r = "Exception: #{message[2]} (#{message[1]}"
			r << "\n\t" << message[3].join( "\n\t")  if message[3]
			r
		when :String, :const then message[1]
		else message.inspect
		end
	reqid = data[:reqid]
	unless @last_reqid == reqid
		@last_reqid = reqid
		puts "\n"
	end
	puts line
end