Permalink
Browse files

Shorten backtraces, unless $DEBUG is set.

  • Loading branch information...
1 parent 09b8c8c commit ff0b0b44705d2837ea33e631263365b47b02c002 @postmodern committed Jun 24, 2011
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/warnings/warning.rb
View
@@ -135,12 +135,18 @@ def to_s
# Will include ANSI color codes, only if `STDOUT` is a TTY Terminal.
#
def print
+ trace = unless $DEBUG
+ @backtrace[0,10]
+ else
+ @backtrace
+ end
+
if $stderr.tty?
$stderr.puts "\e[33m#{@message}:\e[0m"
- @backtrace.each { |line| $stderr.puts "\t\e[2m#{line}\e[0m" }
+ trace.each { |line| $stderr.puts "\t\e[2m#{line}\e[0m" }
else
$stderr.puts "#{@message}:"
- @backtrace.each { |line| $stderr.puts "\t#{line}" }
+ trace.each { |line| $stderr.puts "\t#{line}" }
end
end

0 comments on commit ff0b0b4

Please sign in to comment.