Class: Kitcat::Logging
- Inherits:
-
Object
- Object
- Kitcat::Logging
- 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
-
#migration_name ⇒ Object
readonly
Returns the value of attribute migration_name.
-
#migration_strategy ⇒ Object
readonly
Returns the value of attribute migration_strategy.
Instance Method Summary collapse
- #end_logging ⇒ Object
-
#initialize(migration_strategy, migration_name) ⇒ Logging
constructor
A new instance of Logging.
- #log_failure(item) ⇒ Object
- #log_file_path ⇒ Object
- #log_interrupt_callback_finish ⇒ Object
- #log_interrupt_callback_start ⇒ Object
- #log_success(item) ⇒ Object
- #start_logging ⇒ Object
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_name ⇒ Object (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_strategy ⇒ Object (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_logging ⇒ Object
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_path ⇒ Object
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_finish ⇒ Object
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_start ⇒ Object
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_logging ⇒ Object
19 20 21 |
# File 'lib/kitcat/logging.rb', line 19 def start_logging logger.info 'Start Processing...' end |