22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/wildcloud/logger/middleware/file.rb', line 22
def initialize(app, options = {})
@options = options
@options[:io].sync = true
@queue = Queue.new
@app = app
@thread = Thread.new do
loop do
begin
msg = @queue.pop
if @options[:key]
log = msg[@options[:key]]
else
log = msg[:level].to_s
log << " (#{Time.at(msg[:timestamp])})"
log << " :"
log << " #{msg[:application]}" if msg[:application]
log << " :"
log << " #{msg[:component]}" if msg[:component]
log << " :"
log << " #{msg[:message]}"
end
@options[:io].puts(log)
rescue Exception => e
puts e.message
end
end
end
end
|