DSILog Class Reference

Base class for basic logging functionality. More...

Inherits Simba::Support::ILogger.

Inherited by AETreeLog, ETTreeLog, and PSParseTreeLog.

List of all members.

Public Member Functions

 DSILog (const simba_string &in_fileName, LogLevel in_logLevel, const simba_string &in_logNamespace)
 Constructor.
 DSILog (const simba_wstring &in_fileName)
 Constructor.
const simba_string & GetLocale () const
 Gets the locale for this logger.
virtual LogLevel GetLogLevel () const
 Gets the current LogLevel.
virtual void LogDebug (const simba_char *const in_namespace, const simba_char *const in_className, const simba_char *const in_functionName, const simba_char *const in_messageFormat,...)
 If the log level is greater than or equal to DEBUG, log the message.
virtual void LogError (const simba_char *const in_namespace, const simba_char *const in_className, const simba_char *const in_functionName, const simba_char *const in_messageFormat,...)
 If the log level is greater than or equal to ERROR, log the message.
virtual void LogError (const simba_char *const in_namespace, const simba_char *const in_className, const simba_char *const in_functionName, const ErrorException &in_exception)
 If the log level is greater than or equal to ERROR, log the message.
virtual void LogFatal (const simba_char *const in_namespace, const simba_char *const in_className, const simba_char *const in_functionName, const simba_char *const in_messageFormat,...)
 If the log level is greater than or equal to FATAL, log the message.
virtual void LogFunctionEntrance (const simba_char *const in_namespace, const simba_char *const in_className, const simba_char *const in_functionName)
 If the log level is greater than or equal to DEBUG, log the message.
virtual void LogInfo (const simba_char *const in_namespace, const simba_char *const in_className, const simba_char *const in_functionName, const simba_char *const in_messageFormat,...)
 If the log level is greater than or equal to INFO, log the message.
virtual void LogTrace (const simba_char *const in_namespace, const simba_char *const in_className, const simba_char *const in_functionName, const simba_char *const in_messageFormat,...)
 If the log level is greater than or equal to TRACE, log the message, then log a stack trace.
virtual void LogWarning (const simba_char *const in_namespace, const simba_char *const in_className, const simba_char *const in_functionName, const simba_char *const in_messageFormat,...)
 If the log level is greater than or equal to WARNING, log the message.
virtual void SetFilename (const simba_wstring &in_fileName)
 Sets the filename to log to. If the log file is already open, closes it and re-opens with the new name.
void SetLocale (const simba_string &in_locale)
 Sets the Locale for this logger.
virtual void SetLogLevel (LogLevel in_logLevel)
 Sets a new LogLevel for this logger.
virtual void SetLogNamespace (const simba_string &in_namespace)
 Sets a new LogLevel for this logger.
virtual ~DSILog ()
 Destructor.

Static Public Member Functions

static const simba_char * ConvertLogLevelToCString (LogLevel in_level)
 Converts a log level to a c-string.
static simba_string ConvertLogLevelToString (LogLevel in_level)
 Converts a log level to a simba_string.
static LogLevel ConvertStringToLogLevel (const simba_wstring &in_string)
 Converts a string to a log level.
static LogLevel ConvertStringToLogLevel (const simba_string &in_string)
 Converts a string to a log level.

Protected Member Functions

virtual void FormatLogLine (LogLevel in_logLevel, const simba_char *const in_namespace, const simba_char *const in_className, const simba_char *const in_functionName, const simba_char *const in_messageFormat, simba_string &out_logLine)
 Formats the log line before it is written.
bool IsInLevel (LogLevel in_level)
 Checks if the level provided in the log request is within the acceptable level.
bool IsInNamespace (const simba_char *const in_namespace)
 Checks if the namespace provided in the log request is within the acceptable namespace.
void LogLine (LogLevel in_logLevel, const simba_char *const in_namespace, const simba_char *const in_className, const simba_char *const in_functionName, const simba_char *const in_messageFormat, va_list &in_varArgs)
 Writes the formatted log line to the log file.
void PrepareOStream ()
 Opens the log file.
void ReleaseOStream ()
 Delete the stream object if necessary and set m_ostream to NULL.

Protected Attributes

CriticalSection m_criticalSection
simba_wstring m_fileName
bool m_isFileStream
LogLevel m_level
simba_string m_namespace
FILE * m_outputStream

Detailed Description

Base class for basic logging functionality.

It can be derived to specialize the logging.

NOTE: DSILog will be deprecated in a future version of SimbaEngine SDK. Users of this class are encouraged to use either DSIFileLogger as a drop-in replacement for logging to a file, or to derive from DSILogger in order to specialize logging.


Constructor & Destructor Documentation

DSILog ( const simba_wstring in_fileName  ) 

Constructor.

Parameters:
in_fileName The filename of the file to log to. This should not include an absolute path as it may be configured through external settings.
Exceptions:
SupportException if there is an error opening the log file.
DSILog ( const simba_string &  in_fileName,
LogLevel  in_logLevel,
const simba_string &  in_logNamespace 
)

Constructor.

This creates a DSILog that overrides settings provided by the registry.

Parameters:
in_fileName The filename of the file to log to. This should include an absolute path.
in_logLevel The log level.
in_logNamespace The log namespace.
Exceptions:
SupportException if there is an error opening the log file.
virtual ~DSILog (  )  [virtual]

Destructor.


Member Function Documentation

static const simba_char* ConvertLogLevelToCString ( LogLevel  in_level  )  [static]

Converts a log level to a c-string.

The output values are:

  • OFF
  • FATAL
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • TRACE
  • UNKWN

Note that the values will be padded with spaces to be 5 characters.

Parameters:
in_level The enum for the LogLevel to get the string representation for.
Returns:
The string representation of the LogLevel. (NOT OWN)
static simba_string ConvertLogLevelToString ( LogLevel  in_level  )  [static]

Converts a log level to a simba_string.

The output values are:

  • OFF
  • FATAL
  • ERROR
  • WARN
  • INFO
  • DEBUG
  • TRACE
  • UNKWN

Note that the values will be padded with spaces to be 5 characters.

Parameters:
in_level The enum for the LogLevel to get the string representation for.
Returns:
The string representation of the LogLevel.
static LogLevel ConvertStringToLogLevel ( const simba_wstring in_string  )  [static]

Converts a string to a log level.

Possible input values are:

  • 0 or Off
  • 1 or Fatal
  • 2 or Error
  • 3 or Warning
  • 4 or Info
  • 5 or Debug
  • 6 or Trace

Note that these values are case insensitive.

Parameters:
in_string String representation of a LogLevel.
Returns:
The LogLevel value. (Throws an exception if the value is invalid)
static LogLevel ConvertStringToLogLevel ( const simba_string &  in_string  )  [static]

Converts a string to a log level.

Possible input values are:

  • 0 or Off
  • 1 or Fatal
  • 2 or Error
  • 3 or Warning
  • 4 or Info
  • 5 or Debug
  • 6 or Trace

Note that these values are case insensitive.

Parameters:
in_string String representation of a LogLevel.
Returns:
The LogLevel value. (Throws an exception if the value is invalid)
virtual void FormatLogLine ( LogLevel  in_logLevel,
const simba_char *const   in_namespace,
const simba_char *const   in_className,
const simba_char *const   in_functionName,
const simba_char *const   in_messageFormat,
simba_string &  out_logLine 
) [protected, virtual]

Formats the log line before it is written.

Parameters:
in_logLevel The log level to include in the log line.
in_namespace The namespace of the function attempting to log. (NOT OWN)
in_className The name of the class to log. (NOT OWN)
in_functionName The name of the function to log. (NOT OWN)
in_messageFormat The format of the message to log. (NOT OWN)
out_logLine Formatted log line.

Reimplemented in AETreeLog, ETTreeLog, and PSParseTreeLog.

const simba_string& GetLocale (  )  const [virtual]

Gets the locale for this logger.

This function is not meant to be overridden.

Returns:
The locale for this logger.

Implements ILogger.

virtual LogLevel GetLogLevel (  )  const [virtual]

Gets the current LogLevel.

Returns:
The current LogLevel.

Implements ILogger.

bool IsInLevel ( LogLevel  in_level  )  [protected]

Checks if the level provided in the log request is within the acceptable level.

Parameters:
in_level The level of the function attempting to log.
Returns:
True if the request to log is within the level being logged; false otherwise.
bool IsInNamespace ( const simba_char *const   in_namespace  )  [protected]

Checks if the namespace provided in the log request is within the acceptable namespace.

Parameters:
in_namespace The namespace of the function attempting to log. (NOT OWN)
Returns:
True if the request to log is within the namespace being logged; false otherwise.
virtual void LogDebug ( const simba_char *const   in_namespace,
const simba_char *const   in_className,
const simba_char *const   in_functionName,
const simba_char *const   in_messageFormat,
  ... 
) [virtual]

If the log level is greater than or equal to DEBUG, log the message.

Initializes logger, if it hasn't already.

Parameters:
in_namespace The namespace of the function attempting to log. (NOT OWN)
in_className The name of the class to log. (NOT OWN)
in_functionName The name of the function to log. (NOT OWN)
in_messageFormat The message to log. May contain printf style conversion chars. (NOT OWN)
... Variable arguments list for printf style conversions.
virtual void LogError ( const simba_char *const   in_namespace,
const simba_char *const   in_className,
const simba_char *const   in_functionName,
const simba_char *const   in_messageFormat,
  ... 
) [virtual]

If the log level is greater than or equal to ERROR, log the message.

Initializes logger, if it hasn't already.

Parameters:
in_namespace The namespace of the function attempting to log. (NOT OWN)
in_className The name of the class to log. (NOT OWN)
in_functionName The name of the function to log. (NOT OWN)
in_messageFormat The message to log. May contain printf style conversion chars. (NOT OWN)
... Variable arguments list for printf style conversions.
virtual void LogError ( const simba_char *const   in_namespace,
const simba_char *const   in_className,
const simba_char *const   in_functionName,
const ErrorException in_exception 
) [virtual]

If the log level is greater than or equal to ERROR, log the message.

Initializes logger, if it hasn't already.

Parameters:
in_namespace The namespace of the function attempting to log. (NOT OWN)
in_className The name of the class to log. (NOT OWN)
in_functionName The name of the function to log. (NOT OWN)
in_exception The exception to log.
virtual void LogFatal ( const simba_char *const   in_namespace,
const simba_char *const   in_className,
const simba_char *const   in_functionName,
const simba_char *const   in_messageFormat,
  ... 
) [virtual]

If the log level is greater than or equal to FATAL, log the message.

Initializes logger, if it hasn't already.

Parameters:
in_namespace The namespace of the function attempting to log. (NOT OWN)
in_className The name of the class to log. (NOT OWN)
in_functionName The name of the function to log. (NOT OWN)
in_messageFormat The message to log. May contain printf style conversion chars. (NOT OWN)
... Variable arguments list for printf style conversions.
virtual void LogFunctionEntrance ( const simba_char *const   in_namespace,
const simba_char *const   in_className,
const simba_char *const   in_functionName 
) [virtual]

If the log level is greater than or equal to DEBUG, log the message.

The message will be something similar to: <fileName><functionName> +++++ enter +++++

Initializes logger, if it hasn't already.

Parameters:
in_namespace The namespace of the function attempting to log. (NOT OWN)
in_className The name of the class to log. (NOT OWN)
in_functionName The name of the function to log. (NOT OWN)
virtual void LogInfo ( const simba_char *const   in_namespace,
const simba_char *const   in_className,
const simba_char *const   in_functionName,
const simba_char *const   in_messageFormat,
  ... 
) [virtual]

If the log level is greater than or equal to INFO, log the message.

Initializes logger, if it hasn't already.

Parameters:
in_namespace The namespace of the function attempting to log. (NOT OWN)
in_className The name of the class to log. (NOT OWN)
in_functionName The name of the function to log. (NOT OWN)
in_messageFormat The message to log. May contain printf style conversion chars. (NOT OWN)
... Variable arguments list for printf style conversions.
void LogLine ( LogLevel  in_logLevel,
const simba_char *const   in_namespace,
const simba_char *const   in_className,
const simba_char *const   in_functionName,
const simba_char *const   in_messageFormat,
va_list &  in_varArgs 
) [protected]

Writes the formatted log line to the log file.

Parameters:
in_logLevel The log level to include in the log line.
in_namespace The namespace of the function attempting to log. (NOT OWN)
in_className The name of the class to log. (NOT OWN)
in_functionName The name of the function to log. (NOT OWN)
in_messageFormat The format of the message. (NOT OWN)
in_varArgs The variable argument list for the message.
virtual void LogTrace ( const simba_char *const   in_namespace,
const simba_char *const   in_className,
const simba_char *const   in_functionName,
const simba_char *const   in_messageFormat,
  ... 
) [virtual]

If the log level is greater than or equal to TRACE, log the message, then log a stack trace.

Initializes logger, if it hasn't already.

Parameters:
in_namespace The namespace of the function attempting to log. (NOT OWN)
in_className The name of the class to log. (NOT OWN)
in_functionName The name of the function to log. (NOT OWN)
in_messageFormat The message to log. May contain printf style conversion chars. (NOT OWN)
... Variable arguments list for printf style conversions.
virtual void LogWarning ( const simba_char *const   in_namespace,
const simba_char *const   in_className,
const simba_char *const   in_functionName,
const simba_char *const   in_messageFormat,
  ... 
) [virtual]

If the log level is greater than or equal to WARNING, log the message.

Initializes logger, if it hasn't already.

Parameters:
in_namespace The namespace of the function attempting to log. (NOT OWN)
in_className The name of the class to log. (NOT OWN)
in_functionName The name of the function to log. (NOT OWN)
in_messageFormat The message to log. May contain printf style conversion chars. (NOT OWN)
... Variable arguments list for printf style conversions.
void PrepareOStream (  )  [protected]

Opens the log file.

void ReleaseOStream (  )  [protected]

Delete the stream object if necessary and set m_ostream to NULL.

virtual void SetFilename ( const simba_wstring in_fileName  )  [virtual]

Sets the filename to log to. If the log file is already open, closes it and re-opens with the new name.

Parameters:
in_fileName The filename of the file to log to. This includes the absolute path including directory to log to.
Exceptions:
SupportException if there is an error opening the log file.
void SetLocale ( const simba_string &  in_locale  ) 

Sets the Locale for this logger.

If the locale is not set, then the driver-wide locale is used.

This function is not meant to be overridden.

Parameters:
in_locale The locale for this logger.
virtual void SetLogLevel ( LogLevel  in_logLevel  )  [virtual]

Sets a new LogLevel for this logger.

Parameters:
in_logLevel The new LogLevel.

Implements ILogger.

virtual void SetLogNamespace ( const simba_string &  in_namespace  )  [virtual]

Sets a new LogLevel for this logger.

Parameters:
in_namespace The new logging namespace.

Member Data Documentation

bool m_isFileStream [protected]
LogLevel m_level [protected]
simba_string m_namespace [protected]
FILE* m_outputStream [protected]

The documentation for this class was generated from the following file:

Generated on Wed May 17 14:21:15 2017 for SimbaEngine 10.1.3.1011 by simba