Class: RightScraper::ScraperLogger

Inherits:
Logger
  • Object
show all
Defined in:
lib/right_scraper/scraper_logger.rb

Instance Attribute Summary (collapse)

Attributes inherited from Logger

#repository

Instance Method Summary (collapse)

Methods inherited from Logger

#operation

Constructor Details

- (ScraperLogger) initialize



47
48
49
# File 'lib/right_scraper/scraper_logger.rb', line 47

def initialize
  @errors = []
end

Instance Attribute Details

- (Object) callback

Returns the value of attribute callback



28
29
30
# File 'lib/right_scraper/scraper_logger.rb', line 28

def callback
  @callback
end

- (Object) errors

Returns the value of attribute errors



27
28
29
# File 'lib/right_scraper/scraper_logger.rb', line 27

def errors
  @errors
end

Instance Method Details

- (Object) add(severity, message = nil, progname = nil)



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/right_scraper/scraper_logger.rb', line 30

def add(severity, message=nil, progname=nil)
  if severity >= (self.level || Logger::WARN)
    if message.nil?
      if block_given?
        message = yield
      else
        message = progname
        progname = self.progname
      end
    end
    @errors << [nil, :log,
      {:severity => severity,
        :message => message,
        :progname => progname}]
  end
end

- (Object) note_error(exception, type, explanation = "")



56
57
58
# File 'lib/right_scraper/scraper_logger.rb', line 56

def note_error(exception, type, explanation="")
  @errors << [exception, type, explanation]
end

- (Object) note_phase(phase, type, explanation, exception = nil)



51
52
53
54
# File 'lib/right_scraper/scraper_logger.rb', line 51

def note_phase(phase, type, explanation, exception=nil)
  @callback.call(phase, type, explanation, exception) unless @callback.nil?
  super
end