Class: JobManager::ApplicationLogger

Inherits:
IO
  • Object
show all
Defined in:
lib/jobmanager/applicationlogger.rb

Overview

This class is a base class for all of the ApplicationLogger* classes implemented in this file. This class should not be instantiated directly. This class derives from IO so that it can reuse the print methods (print, <<, puts, etc).

Direct Known Subclasses

ApplicationIOLogger, ApplicationSyslogLogger

Constant Summary collapse

LEVEL_LOGGER_MAP =

This constant is a map between the shortcut methods in the Logger interface (debug, info, warn, etc) and their associated severity constants.

SyslogLogger::LOGGER_LEVEL_MAP.invert

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(job_name, user_name) ⇒ ApplicationLogger

Returns a new instance of ApplicationLogger.



28
29
30
31
# File 'lib/jobmanager/applicationlogger.rb', line 28

def initialize(job_name, user_name)
  @job_name = job_name ? job_name : "UNKNOWN"
  @user_name = user_name
end

Instance Attribute Details

#job_nameObject

Returns the value of attribute job_name.



25
26
27
# File 'lib/jobmanager/applicationlogger.rb', line 25

def job_name
  @job_name
end

#user_nameObject

Returns the value of attribute user_name.



26
27
28
# File 'lib/jobmanager/applicationlogger.rb', line 26

def user_name
  @user_name
end

Instance Method Details

#record_exception(e) ⇒ Object

Description:

This method logs the given exception.



37
38
39
40
# File 'lib/jobmanager/applicationlogger.rb', line 37

def record_exception(e)
  error(e.message)
  debug(e.backtrace.join("\n"))
end

#record_tagged_exception(message, e) ⇒ Object

Description:

This method logs the given exception and the associated tag.



46
47
48
49
# File 'lib/jobmanager/applicationlogger.rb', line 46

def record_tagged_exception(message, e)
  error("#{message}: Error (#{e.class}): #{e.message}")
  debug(e.backtrace.join("\n"))
end

#write(message) ⇒ Object

Description:

This method logs a message with severity level Logger::INFO.



55
56
57
# File 'lib/jobmanager/applicationlogger.rb', line 55

def write(message)
  info(message)
end