Skip to content

Commit

Permalink
Redirect error messages to stderr instead of stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
dskim committed Aug 27, 2012
1 parent a73bab0 commit dec39af
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/sir-sync-a-lot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def push_file(file)
display("Pushing #{file[:path]}...")
AWS::S3::S3Object.store(file[:path], open(file[:path]), read_config[:aws_dest_bucket])
rescue
display("ERROR: Could not push '#{file[:path]}': #{$!.inspect}")
log_error("ERROR: Could not push '#{file[:path]}': #{$!.inspect}")
end

def aquire_lock!
Expand All @@ -267,12 +267,16 @@ def display_help!
end

def exit_with_error!(message)
display("Gah! " + message)
log_error("Gah! " + message)
exit 1
end

def display(message)
puts("[#{Time.now}] #{message}")
def display(message, target=$stdout)
target.puts("[#{Time.now}] #{message}")
end

def log_error(message)
display(message, $stderr)
end

def ask(question)
Expand Down

0 comments on commit dec39af

Please sign in to comment.