Class: JobManager::ApplicationFileLogger

Inherits:
ApplicationIOLogger show all
Defined in:
lib/jobmanager/applicationlogger.rb

Overview

This class provides a Logger interface and logs messages to a file. In addition, it provides a string instance method which allows the caller to retrieve a concatenation of all the messages written to this logger. A number of the interface methods are implemented via the method_missing method.

Constant Summary

Constants inherited from ApplicationIOLogger

JobManager::ApplicationIOLogger::LOGGER_LEVELS

Constants inherited from ApplicationLogger

JobManager::ApplicationLogger::LEVEL_LOGGER_MAP

Instance Attribute Summary

Attributes inherited from ApplicationLogger

#job_name, #user_name

Instance Method Summary collapse

Methods inherited from ApplicationIOLogger

#add, #string

Methods inherited from ApplicationLogger

#record_exception, #record_tagged_exception, #write

Constructor Details

#initialize(log_file, user_name, job_name = nil) ⇒ ApplicationFileLogger

Description:

This method creates a new instance. All further messages written to this instance will be in turn written to the specified log file.



282
283
284
285
286
287
288
289
290
291
292
# File 'lib/jobmanager/applicationlogger.rb', line 282

def initialize(log_file,
               user_name, 
               job_name = nil)
  
  FileUtils.mkdir_p(File.dirname(log_file))
  @log_file_stream = File.open(log_file, "a")
  
  super(@log_file_stream,
        user_name,
        job_name)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JobManager::ApplicationIOLogger

Instance Method Details

#closeObject

Description:

This method closes the log file stream.



298
299
300
# File 'lib/jobmanager/applicationlogger.rb', line 298

def close
  @log_file_stream.close()
end