Class: RightScraper::Loggers::NoisyLogger

Inherits:
RightScraper::Logger show all
Defined in:
lib/right_scraper/loggers/noisy.rb

Overview

A very noisy logger, useful for debugging.

Instance Attribute Summary

Attributes inherited from RightScraper::Logger

#repository

Instance Method Summary collapse

Methods inherited from RightScraper::Logger

#note_warning, #operation

Constructor Details

#initialize(*args) ⇒ NoisyLogger

Initialize the logger, setting the current operation depth to 1.



31
32
33
34
# File 'lib/right_scraper/loggers/noisy.rb', line 31

def initialize(*args)
  super
  @pending = []
end

Instance Method Details

#note_error(exception, type, explanation = "") ⇒ Object



55
56
57
58
59
60
61
62
63
64
# File 'lib/right_scraper/loggers/noisy.rb', line 55

def note_error(exception, type, explanation="")
  recordedtype, recordedexplanation = @pending[-1]
  if recordedtype != type || recordedexplanation != explanation
    @pending.push [type, explanation]
  end
  error("Saw #{exception} during #{context}")
  if recordedtype != type || recordedexplanation != explanation
    @pending.pop
  end
end

#note_phase(phase, type, explanation, exception = nil) ⇒ Object

Note an event to the log, including a visual indicator of how many nested operations are currently pending.

Parameters

phase(Symbol)

phase of operation; one of :begin, :commit, :abort

type(Symbol)

operation type identifier

explanation(String)

explanation of operation

exception(Exception)

optional exception (only if phase is :abort)



44
45
46
47
48
49
50
51
52
53
# File 'lib/right_scraper/loggers/noisy.rb', line 44

def note_phase(phase, type, explanation, exception=nil)
  if phase == :begin
    @pending.push [type, explanation]
  end
  super
  debug("#{depth_str} #{phase} #{immediate_context}")
  unless phase == :begin
    @pending.pop
  end
end