Skip to content

Commit

Permalink
CHEF-400: Make Chef::Application#fatal! log to STDERR for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ Christensen committed Jul 6, 2009
1 parent 0364ca1 commit 2bec83b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion chef/lib/chef/application.rb
Expand Up @@ -82,8 +82,9 @@ def run_application
end

class << self
# Log a fatal error message and exit the application
# Log a fatal error message to both STDERR and the Logger, exit the application
def fatal!(msg, err = -1)
STDERR.puts("FATAL: #{msg}")
Chef::Log.fatal(msg)
Process.exit err
end
Expand Down
7 changes: 6 additions & 1 deletion chef/spec/unit/application_spec.rb
Expand Up @@ -146,10 +146,15 @@
Process.stub!(:exit).and_return(true)
end

it "should log an error message" do
it "should log an error message to the logger" do
Chef::Log.should_receive(:fatal).with("blah").and_return(true)
Chef::Application.fatal! "blah"
end

it "should log an error message on STDERR" do
STDERR.should_receive(:puts).with("FATAL: blah").and_return(true)
Chef::Application.fatal! "blah"
end

describe "when an exit code is supplied" do
it "should exit with the given exit code" do
Expand Down

0 comments on commit 2bec83b

Please sign in to comment.