315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
|
# File 'lib/apache-loggen/base.rb', line 315
def self.execute(conf={}, gen_obj=nil, &block)
config = DEFAULT_CONFIG.merge(conf)
writer = MyWriter.new(config[:filename])
gen_kick = gen_obj && gen_obj.is_a?(Base)
last_rotate = Time.now.to_i
Executors.exec(config) do | context |
if config[:rotate] > 0 && (last_rotate + config[:rotate]) <= Time.now.to_i then
rotated_file = writer.rotate()
if config[:progress] then
$stderr.write "\rfile rotate. rename to #{rotated_file}\n"
end
last_rotate = Time.now.to_i
end
record = gen_obj.generate(context, config) if gen_kick
record = block.call(context, config, record) if block
writer.write(record)
not (config[:limit] > 0 && config[:limit] <= context[:total_count])
end
writer.close
end
|