Class: Kitcat::Logging

Inherits:
Object
  • Object
show all
Defined in:
lib/kitcat/logging.rb

Overview

Kitcat::Logging is used to encapsulate the functionality of Framework related to logging.

It needs to be initialized with the migration_name because this is used to build the relevant log filename.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(migration_strategy, migration_name) ⇒ Logging

Returns a new instance of Logging.



11
12
13
# File 'lib/kitcat/logging.rb', line 11

def initialize(migration_strategy, migration_name)
  @migration_name = build_migration_name(migration_name, migration_strategy)
end

Instance Attribute Details

#migration_nameObject (readonly)

Returns the value of attribute migration_name.



9
10
11
# File 'lib/kitcat/logging.rb', line 9

def migration_name
  @migration_name
end

#migration_strategyObject (readonly)

Returns the value of attribute migration_strategy.



9
10
11
# File 'lib/kitcat/logging.rb', line 9

def migration_strategy
  @migration_strategy
end

Instance Method Details

#end_loggingObject



23
24
25
# File 'lib/kitcat/logging.rb', line 23

def end_logging
  logger.info '...end of processing'
end

#log_failure(item) ⇒ Object



31
32
33
# File 'lib/kitcat/logging.rb', line 31

def log_failure(item)
  log_line(item) { |method| logger.error "...error while processing item: #{item.try(method)}" }
end

#log_file_pathObject



15
16
17
# File 'lib/kitcat/logging.rb', line 15

def log_file_path
  @log_file_path ||= File.join(log_dir, build_log_file_name)
end

#log_interrupt_callback_finishObject



39
40
41
# File 'lib/kitcat/logging.rb', line 39

def log_interrupt_callback_finish
  logger.info '......end of interrupt callback after user interruption'
end

#log_interrupt_callback_startObject



35
36
37
# File 'lib/kitcat/logging.rb', line 35

def log_interrupt_callback_start
  logger.info '...user interrupted, calling interrupt callback on migration strategy...'
end

#log_success(item) ⇒ Object



27
28
29
# File 'lib/kitcat/logging.rb', line 27

def log_success(item)
  log_line(item) { |method| logger.info "...successfully processed item: #{item.try(method)}" }
end

#start_loggingObject



19
20
21
# File 'lib/kitcat/logging.rb', line 19

def start_logging
  logger.info 'Start Processing...'
end