Class: Palmade::Tapsilog::Adapters::FileAdapter
Instance Method Summary
collapse
Methods inherited from BaseAdapter
#initialize
Instance Method Details
#close ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/palmade/tapsilog/adapters/file_adapter.rb', line 26
def close
@services.each do |name, service|
fd = service[:file]
unless fd.nil?
fd.close unless fd.closed?
end
end
end
|
#flush ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/palmade/tapsilog/adapters/file_adapter.rb', line 17
def flush
@services.each do |name, service|
fd = service[:file]
unless fd.nil?
fd.fsync if fd.fileno > 2
end
end
end
|
#write(log_message) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/palmade/tapsilog/adapters/file_adapter.rb', line 4
def write(log_message)
service = log_message[1].to_s
log_message[5] = Palmade::Tapsilog::Utils.hash_to_query_string(log_message[5])
file = get_file_descriptor(service)
if file
log_message.pop if log_message[5].nil? or log_message[5].empty?
file.puts(log_message.join("|"))
else
STDERR.puts "Unknown service: #{service}"
end
end
|