Class: Processor::Observer::Logger

Inherits:
NullObserver show all
Defined in:
lib/processor/observer/logger.rb

Instance Method Summary collapse

Methods inherited from NullObserver

#method_missing

Constructor Details

#initialize(logger = nil, options = {}) ⇒ Logger



7
8
9
10
# File 'lib/processor/observer/logger.rb', line 7

def initialize(logger = nil, options = {})
  @logger_source = logger
  super options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Processor::Observer::NullObserver

Instance Method Details

#after_record_processing(record, result) ⇒ Object



29
30
31
# File 'lib/processor/observer/logger.rb', line 29

def after_record_processing(record, result)
  logger.info "Processed #{id_for record}: #{result}"
end

#before_record_processing(record) ⇒ Object



25
26
27
# File 'lib/processor/observer/logger.rb', line 25

def before_record_processing(record)
  logger.debug "Record #{id_for record} is going to be processed"
end

#processing_error(processor, exception) ⇒ Object



42
43
44
# File 'lib/processor/observer/logger.rb', line 42

def processing_error(processor, exception)
  logger.fatal "Processing #{processor.name} FAILED: #{exception.backtrace}"
end

#processing_finished(processor) ⇒ Object



33
34
35
36
# File 'lib/processor/observer/logger.rb', line 33

def processing_finished(processor)
  logger.info "Processing of #{processor.name} finished."
  messenger.info "Log file saved to #{log_file_name}" if use_log_file?
end

#processing_started(processor) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/processor/observer/logger.rb', line 12

def processing_started(processor)
  initialize_logger(processor)
  logger.info "Processing of #{processor.name} started."

  message = "    Proggress will be saved to the log file. Run\n    tail -f \#{log_file_name}\n    to see log in realtime\n  MESSAGE\n\n  messenger.info message if use_log_file?\nend\n"

#record_processing_error(record, exception) ⇒ Object



38
39
40
# File 'lib/processor/observer/logger.rb', line 38

def record_processing_error(record, exception)
  logger.error "Error processing #{id_for record}: #{exception}"
end