9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/simple_record/logging.rb', line 9
def write_usage(type, domain, q_type, params, results)
if SimpleRecord.usage_logging_options
type_options = SimpleRecord.usage_logging_options[type]
if type_options
file = type_options[:file]
if file.nil?
file = File.open(type_options[:filename], File.exists?(type_options[:filename]) ? "a" : "w")
puts file.path
type_options[:file] = file
end
conditions = params[:conditions][0] if params[:conditions]
line = usage_line(type_options[:format], [type, domain, q_type, conditions, params[:order]], results[:request_id], results[:box_usage])
file.puts line
type_options[:lines] = type_options[:lines] ? type_options[:lines] + 1 : 1
if type_options[:lines] % type_options[:lines_between_flushes] == 0
file.flush
end
end
end
end
|