lib/ruote/log/fancy_printing.rb in ruote-2.3.0.1 vs lib/ruote/log/fancy_printing.rb in ruote-2.3.0.2
- old
+ new
@@ -1,7 +1,7 @@
#--
-# Copyright (c) 2005-2012, John Mettraux, jmettraux@gmail.com
+# Copyright (c) 2005-2013, 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
@@ -75,33 +75,10 @@
fei['subid'][0, 5] + '...',
fei['wfid'] != wfid ? fei['wfid'] : ''
].join('!')
end
- def insp(o, opts={})
-
- case o
- when nil
- 'nil'
- when Hash
- trim = opts[:trim] || []
- '{' +
- o.reject { |k, v|
- v.nil? && trim.include?(k.to_s)
- }.collect { |k, v|
- "#{k}: #{insp(v)}"
- }.join(', ') +
- '}'
- when Array
- '[' + o.collect { |e| insp(e) }.join(', ') + ']'
- when String
- o.match(/\s/) ? o.inspect : o
- else
- o.inspect
- end
- end
-
def radial_tree(msg)
_, t = Ruote::Exp::DefineExpression.reorganize(msg['tree'])
Ruote::Reader.to_expid_radial(t).split("\n").inject('') do |s, l|
@@ -115,14 +92,17 @@
def fancy_print(msg, noisy=true)
@count = (@count + 1) % 10
- ei = [
- self.object_id.to_s[-2..-1],
- Thread.current['worker_name'].to_s[0, 2]
- ].join(':')
+ wo = Ruote.current_worker
+ woi = [ wo.object_id.to_s[-2..-1] ]
+ if wo.class != Ruote::Worker || wo.name != 'worker'
+ woi << wo.class.name.split('::').last[0, 2]
+ woi << wo.name[0, 2]
+ end
+ woi = woi.join(':')
fei = msg['fei']
depth = fei ? fei['expid'].split('_').size : 0
i = fei ?
@@ -208,11 +188,11 @@
s = if %w[ error_intercepted raise ].include?(msg['action'])
#
# display backtraces
- rst = insp(
+ rst = Ruote.insp(
rest.reject { |k, v| %w[ error msg ].include?(k) },
:trim => %[ updated_tree ])[1..-2]
tail = []
tail << " #{wfid} * class: #{rest['error']['class']}"
@@ -223,11 +203,11 @@
trace.each { |line| tail << " #{wfid} #{line}" }
color(
@color,
- "#{@count} #{tm} #{ei} #{' ' * depth}#{act} * #{i} #{rst}",
+ "#{@count} #{tm} #{woi} #{' ' * depth}#{act} * #{i} #{rst}",
true
) +
"\n" +
color(
@color,
@@ -242,14 +222,14 @@
color('34', rest.delete('participant_name')) + ' '
else
''
end
- rest = insp(rest, :trim => %[ updated_tree ])[1..-2]
+ rest = Ruote.insp(rest, :trim => %[ updated_tree ])[1..-2]
color(
@color,
- "#{@count} #{tm} #{ei} #{' ' * depth}#{act} * #{i} #{pa}#{rest}",
+ "#{@count} #{tm} #{woi} #{' ' * depth}#{act} * #{i} #{pa}#{rest}",
true)
end
s << radial_tree(msg) if fei.nil? && msg['action'] == 'launch'