Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'cprice-puppet/bug/master/13929-exit-on-…

…fail-logging'

* cprice-puppet/bug/master/13929-exit-on-fail-logging:
  (#13929) Improve logging for very early failures
  • Loading branch information...
commit 32172d5d8de35f5cdbc31bce327b3567e078bb83 2 parents e8d8d68 + 03bf1a6
@jeffweiss jeffweiss authored
Showing with 15 additions and 0 deletions.
  1. +1 −0  lib/puppet/util.rb
  2. +14 −0 lib/puppet/util/log.rb
View
1  lib/puppet/util.rb
@@ -504,6 +504,7 @@ def exit_on_fail(message, code = 1)
# code (e.g. webrick), and we have no idea what they might throw.
rescue Exception => err
Puppet.log_exception(err, "Could not #{message}: #{err}")
+ Puppet::Util::Log.force_flushqueue()
exit(code)
end
module_function :exit_on_fail
View
14 lib/puppet/util/log.rb
@@ -170,6 +170,20 @@ def Log.flushqueue
@queued.clear
end
+ # Flush the logging queue. If there are no destinations available,
+ # adds in a console logger before flushing the queue.
+ # This is mainly intended to be used as a last-resort attempt
+ # to ensure that logging messages are not thrown away before
+ # the program is about to exit--most likely in a horrific
+ # error scenario.
+ # @return nil
+ def Log.force_flushqueue()
+ if (@destinations.empty? and !(@queued.empty?))
+ newdestination(:console)
+ end
+ flushqueue
+ end
+
def Log.sendlevel?(level)
@levels.index(level) >= @loglevel
end

0 comments on commit 32172d5

Please sign in to comment.
Something went wrong with that request. Please try again.