Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Jeff Weiss authored April 13, 2012
1  lib/puppet/util.rb
@@ -504,6 +504,7 @@ def exit_on_fail(message, code = 1)
504 504
   #  code (e.g. webrick), and we have no idea what they might throw.
505 505
   rescue Exception => err
506 506
     Puppet.log_exception(err, "Could not #{message}: #{err}")
  507
+    Puppet::Util::Log.force_flushqueue()
507 508
     exit(code)
508 509
   end
509 510
   module_function :exit_on_fail
14  lib/puppet/util/log.rb
@@ -170,6 +170,20 @@ def Log.flushqueue
170 170
     @queued.clear
171 171
   end
172 172
 
  173
+  # Flush the logging queue.  If there are no destinations available,
  174
+  #  adds in a console logger before flushing the queue.
  175
+  # This is mainly intended to be used as a last-resort attempt
  176
+  #  to ensure that logging messages are not thrown away before
  177
+  #  the program is about to exit--most likely in a horrific
  178
+  #  error scenario.
  179
+  # @return nil
  180
+  def Log.force_flushqueue()
  181
+    if (@destinations.empty? and !(@queued.empty?))
  182
+      newdestination(:console)
  183
+    end
  184
+    flushqueue
  185
+  end
  186
+
173 187
   def Log.sendlevel?(level)
174 188
     @levels.index(level) >= @loglevel
175 189
   end

0 notes on commit 32172d5

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