Class: Jekyll::LogAdapters::Tap::Logger

Inherits:
Stevenson
  • Object
show all
Defined in:
lib/jekyll/log_adapters/tap.rb

Constant Summary collapse

SEVERITY_FORMAT =

TAP doesn’t have that many levels, so we differentiate errors from warnings by color and prefix.

See Also:

  • Logger::Severity
{
  'DEBUG' => '#',
  'INFO'  => 'ok -',
  'WARN'  => 'not ok - Warning:',
  'ERROR' => 'not ok - Error:',
  'FATAL' => 'Bail out!',
  'ANY'   => ''
}
SEVERITY_COLOR =
{
  'DEBUG' => [],
  'INFO'  => %i[green],
  'WARN'  => %i[yellow],
  'ERROR' => %i[red],
  'FATAL' => %i[red bold],
  'ANY'   => []
}
COUNT_TESTS =
(1..3)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogger

Replace the formatter with a proc

Multi-line messages are assumed to be debug level, like the profiler table.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/jekyll/log_adapters/tap.rb', line 41

def initialize
  super

  logdevice(1).puts('TAP version 14')

  # Initialize counter
  @test_counter = 0
  # At this point, severity is an Integer
  @formatter = proc do |severity, _, _, msg|
    msg = msg.to_s.strip_ansi.strip

    next if msg.empty?

    if msg.lines.size > 1
      msg.lines.map do |line|
        "#{tap_format(0)} #{line}"
      end.join
    else
      "#{tap_format(severity)} #{msg}"
    end
  end
end

Instance Attribute Details

#test_counterObject (readonly)

Returns the value of attribute test_counter.



35
36
37
# File 'lib/jekyll/log_adapters/tap.rb', line 35

def test_counter
  @test_counter
end

Instance Method Details

#closeObject



64
65
66
# File 'lib/jekyll/log_adapters/tap.rb', line 64

def close
  logdevice(0).puts("1..#{@test_counter}")
end