Module: Fasten::Support::Logger
Instance Attribute Summary collapse
-
#log_file ⇒ Object
Returns the value of attribute log_file.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #close_logger ⇒ Object
- #initialize_logger(log_file: nil) ⇒ Object
- #log_fin(object, message = nil) ⇒ Object
- #log_ini(object, message = nil) ⇒ Object
Instance Attribute Details
#log_file ⇒ Object
Returns the value of attribute log_file.
12 13 14 |
# File 'lib/fasten/support/logger.rb', line 12 def log_file @log_file end |
#logger ⇒ Object
Returns the value of attribute logger.
12 13 14 |
# File 'lib/fasten/support/logger.rb', line 12 def logger @logger end |
Instance Method Details
#close_logger ⇒ Object
37 38 39 |
# File 'lib/fasten/support/logger.rb', line 37 def close_logger logger.close if logger.is_a? ::Logger end |
#initialize_logger(log_file: nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fasten/support/logger.rb', line 25 def initialize_logger(log_file: nil) if log_file self.log_file = log_file else self.log_file ||= "#{fasten_dir}/log/#{kind}/#{name}.log" FileUtils.mkdir_p File.dirname(self.log_file) end close_logger self.logger = ::Logger.new self.log_file, level: Fasten.logger.level, progname: Fasten.logger.progname end |
#log_fin(object, message = nil) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/fasten/support/logger.rb', line 46 def log_fin(object, = nil) object.fin ||= Time.new object.dif = object.fin - object.ini log_info "Fin #{object.state} #{object.class} #{object} #{} in #{object.dif}" end |
#log_ini(object, message = nil) ⇒ Object
41 42 43 44 |
# File 'lib/fasten/support/logger.rb', line 41 def log_ini(object, = nil) object.ini ||= Time.new log_info "Ini #{object.state} #{object.class} #{object} #{}" end |