Permalink
Browse files

more logger methods

  • Loading branch information...
1 parent 21506cf commit 1c6e904fb069ca62be174a66fb6d1c283f4b886f @gnufied committed Oct 4, 2008
Showing with 11 additions and 23 deletions.
  1. +4 −4 lib/backgroundrb/bdrb_job_queue.rb
  2. +1 −1 lib/backgroundrb/bdrb_start_stop.rb
  3. +6 −18 server/lib/meta_worker.rb
@@ -11,7 +11,7 @@ def self.find_next(worker_name,worker_key = nil)
end
if t_job
t_job.taken = 1
- t_job.started_at = Time.now
+ t_job.started_at = Time.now.utc
t_job.save
returned_job = t_job
end
@@ -29,7 +29,7 @@ def release_job
def self.insert_job(options = { })
transaction do
- options.merge!(:submitted_at => Time.now,:finished => 0,:taken => 0)
+ options.merge!(:submitted_at => Time.now.utc,:finished => 0,:taken => 0)
t_job = new(options)
t_job.save
end
@@ -45,8 +45,8 @@ def self.remove_job(options = { })
def finish!
self.class.transaction do
self.finished = 1
- self.finished_at = Time.now
- self.job_key = "finished_#{Time.now.to_i}_#{job_key}"
+ self.finished_at = Time.now.utc
+ self.job_key = "finished_#{Time.now.utc.to_i}_#{job_key}"
self.save
end
Thread.current[:persistent_job_id] = nil
@@ -25,7 +25,7 @@ def start
op.write(Process.pid().to_s)
op.close
if BDRB_CONFIG[:backgroundrb][:log].nil? or BDRB_CONFIG[:backgroundrb][:log] != 'foreground'
- log_file = File.open(SERVER_LOGGER,"w+")
+ log_file = File.open(SERVER_LOGGER,"a")
[STDIN, STDOUT, STDERR].each {|desc| desc.reopen(log_file)}
end
View
@@ -7,24 +7,12 @@ def initialize(worker,log_flag = true)
@worker = worker
@log_mutex = Mutex.new
end
- def info(p_data)
- return unless @log_flag
- @log_mutex.synchronize do
- @worker.send_request(:worker => :log_worker, :data => p_data)
- end
- end
-
- def debug(p_data)
- return unless @log_flag
- @log_mutex.synchronize do
- @worker.send_request(:worker => :log_worker, :data => p_data)
- end
- end
-
- def error(p_data)
- return unless @log_flag
- @log_mutex.synchronize do
- @worker.send_request(:worker => :log_worker, :data => p_data)
+ [:info,:debug,:warn,:error,:fatal].each do |m|
+ define_method(m) do |log_data|
+ return unless @log_flag
+ @log_mutex.synchronize do
+ @worker.send_request(:worker => :log_worker, :data => log_data)
+ end
end
end
end

0 comments on commit 1c6e904

Please sign in to comment.