Class: Semlogger::Writer

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

Instance Method Summary collapse

Constructor Details

#initialize(logdev = nil) ⇒ Writer

Returns a new instance of Writer.



5
6
7
8
9
10
11
# File 'lib/semlogger/writer.rb', line 5

def initialize logdev = nil
	@logdev = case logdev
		when String then ::Semlogger::Rotate.new logdev
		when nil then ::Semlogger::Rotate.new "log/#{File.basename $0}.%Y-%m-%d.%$.log"
		else logdev
		end
end

Instance Method Details

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



13
14
15
# File 'lib/semlogger/writer.rb', line 13

def add severity, time, progname, data, tags, message
	@logdev.write [severity, time.xmlschema(9), progname, data, tags, message].to_json+"\n"
end