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

#initializeScraperLogger

Returns a new instance of ScraperLogger.



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

def initialize
  @errors = []
  @warnings = []
end

Instance Attribute Details

#callbackObject

Returns the value of attribute callback.



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

def callback
  @callback
end

#errorsObject

Returns the value of attribute errors.



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

def errors
  @errors
end

#warningsObject

Returns the value of attribute warnings.



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

def warnings
  @warnings
end

Instance Method Details

#add(severity, message = nil, progname = nil) ⇒ Object



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

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

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



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

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

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



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

#note_warning(message) ⇒ Object



60
61
62
# File 'lib/right_scraper/scraper_logger.rb', line 60

def note_warning(message)
  @warnings << message
end