Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_LogFile Class Reference

CP_LogFile. More...

Inheritance diagram for CP_LogFile:

CP_BufferedLogFile List of all members.

Public Member Functions

void SetLevel (UInt32 inLevel)
UInt32 GetLevel () const
UInt32 GetMode () const
void SetOptions (UInt32 inOptions)
UInt32 GetOptions () const
CP_E_LogFile_Status GetStatus () const
const char * GetFilename () const
void SetSyslogPriorityThreshold (int inSysLogPriority, UInt32 inLogLevelThreshold)
 Set the threshold to use a specific syslog priority.
void SetSyslogFacility (int inSysLogFacility)
Constructor / Destructor
 CP_LogFile ()
 Constructor.
virtual ~CP_LogFile ()
 Destructor.

Protected Member Functions

Logging
virtual SInt32 LogMessageSelf (const char *inMessage, UInt32 inLevel)

Protected Attributes

FILE * fOutfile
UInt32 fOptions
UInt32 fLevel
CP_E_LogFile_Status fStatus
UInt32 fMode
UInt32 fCount
char fFile [255]
bool fEmptyFileFlag
bool fLogToFileFlag
char fMessage [1024]
char fBuffer [1024]
char fBuffer1 [1024]
UInt32 fSyslogPriorityThresholds [32]
int fSyslogFacility
CP_Mutex fBufferMutex
 mutex to synchronize access to fBuffer.
CP_Mutex fLogMutex
 mutex to serialize LogMessage calls

Private Member Functions

Constructor / Destructor
 CP_LogFile (const CP_LogFile &)
 Constructor.
Logging
void LogMessageToDebugger (char *inMsg)
operators
CP_LogFileoperator= (const CP_LogFile &)

Detailed Description

Class to handle logging of messages to either a file or a debugger.


Constructor & Destructor Documentation

CPLAT_Begin_Namespace_CPLAT CP_LogFile::CP_LogFile  ) 
 

Constructor.

Exceptions:
none 

CP_LogFile::~CP_LogFile  )  [virtual]
 

Destructor.

Exceptions:
none 

CP_LogFile::CP_LogFile const CP_LogFile  )  [private]
 


Member Function Documentation

SInt32 CP_LogFile::Start const char *  inFile,
UInt32  inMode = CP_E_LogOptions_ExplicitPath | CP_E_LogOptions_LogToDebug,
UInt32  inOptions = CP_E_LogFile_ShowAll,
UInt32  inLevel = 0
 

Start logging messages to this class.

Parameters:
inFile The name of the log file produced.
inMode Controls where / how the log file is created.
inOptions Sets the CP_E_LogFile_LogOptions used in this class.
inLevel Sets the level used to control the indenting of the messages.
Exceptions:
none 
Returns:
SInt32 Returns the status of the log file, and can be one of the following values:
  • CP_E_LogReturn_Success,
  • CP_E_LogReturn_UnableToOpenFile,
  • CP_E_LogReturn_NotLogging,
  • CP_E_LogReturn_NotPaused,
  • CP_E_LogReturn_AlreadyStarted,
  • CP_E_LogReturn_NoLoggingModeSpecified,
  • CP_E_LogReturn_TooManyModesSpecified

SInt32 CP_LogFile::Start const CP_FileSystemSpec inFileSpec,
UInt32  inMode = CP_E_LogOptions_ExplicitPath | CP_E_LogOptions_LogToDebug,
UInt32  inOptions = CP_E_LogFile_ShowAll,
UInt32  inLevel = 0
 

Start logging messages to this class.

Parameters:
inSpec File system spec of the log file produced.
inMode Controls where / how the log file is created.
inOptions Sets the CP_E_LogFile_LogOptions used in this class.
inLevel Sets the level used to control the indenting of the messages.
Exceptions:
none 
Returns:
SInt32 Returns the status of the log file, and can be one of the following values:
  • CP_E_LogReturn_Success,
  • CP_E_LogReturn_UnableToOpenFile,
  • CP_E_LogReturn_NotLogging,
  • CP_E_LogReturn_NotPaused,
  • CP_E_LogReturn_AlreadyStarted,
  • CP_E_LogReturn_NoLoggingModeSpecified,
  • CP_E_LogReturn_TooManyModesSpecified

SInt32 CP_LogFile::Start UInt32  inMode = CP_E_LogOptions_LogToDebug,
UInt32  inOptions = CP_E_LogFile_ShowAll,
UInt32  inLevel = 0
 

Start logging messages to this class. This version does not specify a file name.

Parameters:
inMode Controls where / how the log file is created.
inOptions Sets the CP_E_LogFile_LogOptions used in this class.
inLevel Sets the level used to control the indenting of the messages.
Exceptions:
none 
Returns:
SInt32 Returns the status of the log file, and can be one of the following values:
  • CP_E_LogReturn_Success,
  • CP_E_LogReturn_UnableToOpenFile,
  • CP_E_LogReturn_NotLogging,
  • CP_E_LogReturn_NotPaused,
  • CP_E_LogReturn_AlreadyStarted,
  • CP_E_LogReturn_NoLoggingModeSpecified,
  • CP_E_LogReturn_TooManyModesSpecified

SInt32 CP_LogFile::Pause  ) 
 

Temporarily pause the logging of messages, and sets the status to CP_E_LogStatus_Paused.

Exceptions:
none 
Returns:
SInt32 Returns CP_E_LogReturn_Success.

SInt32 CP_LogFile::Continue  ) 
 

Continue logging of messages. Call this if you have paused logging, and sets the status to CP_E_LogStatus_Ready.

Exceptions:
none 
Returns:
SInt32 Returns CP_E_LogReturn_Success.

SInt32 CP_LogFile::Stop  ) 
 

Stop logging messages to this class.

Exceptions:
none 
Returns:
SInt32 Returns the status of the log file, and can be one of the following values:
  • CP_E_LogStatus_NotCP_E_LogStatus_Ready,
  • CP_E_LogStatus_Ready,
  • CP_E_LogStatus_Paused

SInt32 CP_LogFile::LogMessage const char *  inMessage,
UInt32  inLevel = 0
 

Log a message to the log.

Parameters:
inMsg The text of the message.
inLevel The indent level of the message.
Exceptions:
none 
Returns:
SInt32 Returns one of the status messages to indicate the sucess of writing the message. Currently we only return CP_E_LogReturn_Success.

SInt32 CP_LogFile::LogMessage UInt32  inLevel,
const char *  formatStr,
  ...
 

Log a formatted message.

Parameters:
inLevel The level of the message.
formatStr Controls how any remaining parameters are interpreted in the formatting of the message.
Exceptions:
none 
Returns:
SInt32 Returns the status of the logging.

SInt32 CP_LogFile::VLogMessage UInt32  inLevel,
const char *  formatStr,
va_list  args
 

Log a formatted message.

Parameters:
inLevel The level of the message.
formatStr Controls how any remaining parameters are interpreted in the formatting of the message.
args Variable list of additional params.
Exceptions:
none 
Returns:
SInt32 Returns the status of the logging.

void CP_LogFile::SetLevel UInt32  inLevel  ) 
 

Set the level of the error, which controls the level of indenting in the file.

Parameters:
inLevel The level of indenting to use.
Exceptions:
none 
Returns:
void

UInt32 CP_LogFile::GetLevel  )  const
 

Returns the level of the error.

Exceptions:
none 
Returns:
UInt32 The level of indenting.

UInt32 CP_LogFile::GetMode  )  const
 

Returns the logging mode in use, which controls where / how the log file is created.

Exceptions:
none 
Returns:
UInt32 The mode in use.

void CP_LogFile::SetOptions UInt32  inOptions  ) 
 

Sets the options that control varius aspects of how the logging takes place. The following are valid options to pass in:

  • CP_E_LogOptions_ExplicitPath
  • CP_E_LogOptions_TempDirectory
  • CP_E_LogOptions_LogDirectory
  • CP_E_LogOptions_SystemLogDirectory
  • CP_E_LogOptions_DeleteIfEmpty
  • CP_E_LogOptions_AppendFile
  • CP_E_LogOptions_LogToDebug
  • CP_E_LogOptions_LogToConsole
  • CP_E_LogOptions_LogToSyslog

Exceptions:
none 
Returns:
void

UInt32 CP_LogFile::GetOptions  )  const
 

Returns the logging options in effect.

Exceptions:
none 
Returns:
UInt32 The current logging options.

CP_E_LogFile_Status CP_LogFile::GetStatus  )  const
 

Returns the current status of the log file, and can be one of the following values:

  • CP_E_LogStatus_NotCP_E_LogStatus_Ready,
  • CP_E_LogStatus_Ready,
  • CP_E_LogStatus_Paused

Exceptions:
none 
Returns:
CP_E_LogFile_Status The current log file status.

const char* CP_LogFile::GetFilename  )  const
 

Returns the file name of the log.

Exceptions:
none 
Returns:
const char * The file name of the log.

void CP_LogFile::SetSyslogPriorityThreshold int  inSysLogPriority,
UInt32  inLogLevelThreshold
 

Defines the threshold of when to use the specified syslog level:
A log message will be logged with the largest syslog priority for which the threshold is less or equal to the message level. The default level, if nothing else set is to use LOG_INFO.

Note:
Thresholds are examined in order of descending syslog priority. This means that you'll have to specify increasing log levels to decreasing syslog priorities, otherwise, the highest syslog priority that has a log level which is larger than the message level will be used.
Example:
  • LOG_CRIT mapped to threshold 3
  • LOG_ERR mapped to threshold 10
  • LOG_WARNING mapped to threshold 20 A message level of 5 will be reported as LOG_CRIT, a message level of 2 will not be reported, a message level of 15 will be reported as LOG_ERR, etc.
Parameters:
inSysLogPriority The syslog priority for which to set the threshold.
inLogLevelThreshold The log level threshold when to use this priority (see above). Pass UINT_MAX to disable logging with this priority.
Exceptions:
none 
Returns:
void

void CP_LogFile::SetSyslogFacility int  inSysLogFacility  ) 
 

Set the sys log facility.

Parameters:
inSysLogFacility The syslog facility.
Exceptions:
none 
Returns:
void

SInt32 CP_LogFile::LogMessageSelf const char *  inMsg,
UInt32  inLevel
[protected, virtual]
 

Log a message to the log.

Parameters:
inMsg The text of the message.
inLevel The indent level of the message.
Exceptions:
none 
Returns:
SInt32 Returns CP_E_LogReturn_Success.

Reimplemented in CP_BufferedLogFile.

void CP_LogFile::LogMessageToDebugger char *  inMsg  )  [private]
 

Log a message to the MacOS debugger

Parameters:
inMsg The text of the message.
Exceptions:
none 
Returns:
void

CP_LogFile& CP_LogFile::operator= const CP_LogFile  )  [private]
 


Member Data Documentation

FILE* CP_LogFile::fOutfile [protected]
 

UInt32 CP_LogFile::fOptions [protected]
 

UInt32 CP_LogFile::fLevel [protected]
 

CP_E_LogFile_Status CP_LogFile::fStatus [protected]
 

UInt32 CP_LogFile::fMode [protected]
 

UInt32 CP_LogFile::fCount [protected]
 

char CP_LogFile::fFile[255] [protected]
 

bool CP_LogFile::fEmptyFileFlag [protected]
 

bool CP_LogFile::fLogToFileFlag [protected]
 

char CP_LogFile::fMessage[1024] [protected]
 

char CP_LogFile::fBuffer[1024] [protected]
 

char CP_LogFile::fBuffer1[1024] [protected]
 

UInt32 CP_LogFile::fSyslogPriorityThresholds[32] [protected]
 

int CP_LogFile::fSyslogFacility [protected]
 

CP_Mutex CP_LogFile::fBufferMutex [protected]
 

CP_Mutex CP_LogFile::fLogMutex [protected]
 


The documentation for this class was generated from the following files:
Generated on Tue Sep 20 20:21:51 2005 for CPLAT_MacOS by  doxygen 1.4.0