# File lib/ruote/log/pretty.rb, line 75
    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(' ') :
        msg['wfid']

      rest = msg.dup
      %w[
        _id put_at _rev
        type action
        fei wfid variables
      ].each { |k| rest.delete(k) }

      if v = rest['parent_id']
        rest['parent_id'] = Ruote.to_storage_id(v)
      end
      if v = rest.delete('workitem')
        rest[:wi] = [
          v['fei'] ? Ruote.to_storage_id(v['fei']) : nil,
          v['fields'].size ]
      end

      { 'tree' => :t, 'parent_id' => :pi }.each do |k0, k1|
        if v = rest.delete(k0)
          rest[k1] = v
        end
      end

      action = msg['action'][0, 2]
      action = case msg['action']
        when 'receive' then 'rc'
        when 'dispatched' then 'dd'
        when 'dispatch_cancel' then 'dc'
        else action
      end
      action = case action
        when 'la' then color('4;32', action)
        when 'te' then color('4;31', action)
        when 'ce' then color('31', action)
        when 'ca' then color('31', action)
        when 'rc' then color('4;33', action)
        when 'di' then color('4;33', action)
        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)
    end