lib/ruote/log/pretty.rb in ruote-2.1.11 vs lib/ruote/log/pretty.rb in ruote-2.2.0
- old
+ new
@@ -1,7 +1,7 @@
#--
-# Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com
+# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -62,31 +62,32 @@
# 45 Magenta
# 46 Cyan
# 47 White
#++
- def color (mod, s, clear=false)
+ def color(mod, s, clear=false)
return s if Ruote::WIN
return s unless STDOUT.tty?
"[#{mod}m#{s}[0m#{clear ? '' : "[#{@color}m"}"
end
- def pretty_print (msg)
+ def pretty_print(msg)
@count += 1
@count = 0 if @count > 9
ei = self.object_id.to_s[-2..-1]
fei = msg['fei']
depth = fei ? fei['expid'].split('_').size : 0
i = fei ?
- [ fei['wfid'], fei['sub_wfid'], fei['expid'] ].join(' ') :
+ [ fei['wfid'], (fei['subid'] || '')[0, 5], fei['expid'] ].join(' ') :
msg['wfid']
+ wfid = fei ? fei['wfid'] : msg['wfid']
rest = msg.dup
%w[
_id put_at _rev
type action
@@ -100,10 +101,14 @@
rest[:wi] = [
v['fei'] ? Ruote.to_storage_id(v['fei']) : nil,
v['fields'].size ]
end
+ #if t = rest.delete('tree')
+ # rest[:t] = color(37, t.inspect, true)
+ #end
+
{ 'tree' => :t, 'parent_id' => :pi }.each do |k0, k1|
if v = rest.delete(k0)
rest[k1] = v
end
end
@@ -125,13 +130,36 @@
when 'dd' then color('4;33', action)
when 'dc' then color('4;31', action)
else action
end
- color(
- @color,
- "#{@count} #{ei} #{' ' * depth}#{action} * #{i} #{rest.inspect}",
- true)
+ if msg['action'] == 'error_intercepted'
+
+ tail = []
+ tail << " #{wfid} #{rest['error']['class']}"
+ tail << " #{wfid} #{rest['error']['message']}"
+ rest['error']['trace'].each do |line|
+ tail << " #{wfid} #{line}"
+ end
+
+ color(
+ @color,
+ "#{@count} #{ei} #{' ' * depth}#{action} * #{i}",
+ true
+ ) +
+ "\n" +
+ color(
+ @color,
+ tail.join("\n"),
+ true)
+
+ else
+
+ color(
+ @color,
+ "#{@count} #{ei} #{' ' * depth}#{action} * #{i} #{rest.inspect}",
+ true)
+ end
end
end
end