Class/Module Index [+]

Quicksearch

Ruote::PrettyLogging

A container for the pretty printing logic of TestLogger.

Protected Instance Methods

color(mod, s, clear=false) click to toggle source
# File lib/ruote/log/pretty.rb, line 67
def color (mod, s, clear=false)

  return s if Ruote::WIN
  return s unless STDOUT.tty?

  "[#{mod}m#{s}#{clear ? '' : "[#{@color}m"}"
end
pretty_print(msg) click to toggle source
# 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
  ]
    _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

[Validate]

Generated with the Darkfish Rdoc Generator 2.