Please review pull request #512: Minor improvement to backtrace logging opened by (cprice-puppet)

Description:

With --trace and log_exception(), backtrace logs were being printed
without line separators between them. This simply cleans up the
formatting so that each hop in the stack is printed on its own line.

  • Opened: Fri Feb 17 19:11:51 UTC 2012
  • Based on: puppetlabs:master (69db777c3ad5dd4c91db5046d5d4ab928350242f)
  • Requested merge: cprice-puppet:feature/master/improve-backtrace-logging (537718f15bb3361474e4ae67ae01bda6ce4b6840)

Diff follows:

diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index e7570f8..b3f8b4b 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -373,8 +373,8 @@ def binread(file)
 
   # utility method to get the current call stack and format it to a human-readable string (which some IDEs/editors
   # will recognize as links to the line numbers in the trace)
-  def self.pretty_backtrace()
-    caller(1).collect do |line|
+  def self.pretty_backtrace(backtrace = caller(1))
+    backtrace.collect do |line|
       file_path, line_num = line.split(":")
       file_path = expand_symlinks(File.expand_path(file_path))
 
diff --git a/lib/puppet/util/logging.rb b/lib/puppet/util/logging.rb
index 929310d..bdb0bbf 100644
--- a/lib/puppet/util/logging.rb
+++ b/lib/puppet/util/logging.rb
@@ -33,7 +33,7 @@ def log_exception(exception, message = :default)
         err(message)
     end
 
-    err(exception.backtrace) if Puppet[:trace] && exception.backtrace
+    err(Puppet::Util.pretty_backtrace(exception.backtrace)) if Puppet[:trace] && exception.backtrace
   end
 
   class DeprecationWarning < Exception; end

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to