Skip to content

Commit

Permalink
log error messages to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcgrana authored and Adam Wiggins committed Aug 5, 2010
1 parent 3904404 commit f681fc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions lib/stalker.rb
Expand Up @@ -66,16 +66,16 @@ def work_one_job
rescue SystemExit
raise
rescue => e
log exception_message(e)
log_error exception_message(e)
job.bury rescue nil
log_job_end(name, 'failed')
error_handler.call(e) if error_handler
end

def failed_connection(e)
STDERR.puts exception_message(e)
STDERR.puts "*** Failed connection to #{beanstalk_url}"
STDERR.puts "*** Check that beanstalkd is running (or set a different BEANSTALK_URL)"
log_error exception_message(e)
log_error "*** Failed connection to #{beanstalk_url}"
log_error "*** Check that beanstalkd is running (or set a different BEANSTALK_URL)"
exit 1
end

Expand All @@ -102,6 +102,10 @@ def log(msg)
puts "[#{Time.now}] #{msg}"
end

def log_error(msg)
STDERR.puts msg
end

def beanstalk
@@beanstalk ||= Beanstalk::Pool.new([ beanstalk_host_and_port ])
end
Expand Down
4 changes: 2 additions & 2 deletions test/stalker_test.rb
Expand Up @@ -3,8 +3,8 @@
require 'mocha'

module Stalker
def log(msg)
end
def log(msg); end
def log_error(msg); end
end

class StalkerTest < Test::Unit::TestCase
Expand Down

0 comments on commit f681fc4

Please sign in to comment.