ccTraceFile

09/08/99

Author: Daniel.Lindh@Home.se
ICQ: 7983755
HOMEPAGE: home.bip.net/CyberCow

Copyright © Cyber Cow 1995 - 1999.
All Rights Reserved.

OverView
Class Members
Base Class CStdioFile

 

Overview

#include <ccTraceFile.h>

Hierarchy Chart


A ccTraceFile object handles text-message logging to a file. This can be used for debugging, error logging, script logging, session logging etc.

 

Class Members

Data Items:

Private:

None

Construction

Public:

ccTraceFile Constructs a ccTracefile object.
enableLogging Turn on and of the file logging.

Properies

Public:

setFileName

Set the name of the tracefile.

browseTraceFile

Opening a save as dialog, from which the user can select the trace file name.

getFileName

Get the name of the tracefile.
setLogSize The size in kbytes the log file can have. When it reaches this size it will dispaly a warning message.
getLogsize The size in kbytes the log file can have.

Protected:

None

Private:

None

Input/Output

Public:

addMessage Adds a message to the tracefile.
view View the information in the tracefile from notepad.
clear Clear the trace file.

Protected:

Nones

Private:

None

Status

Public:

isTraceing Check if the trace has been started.

Protected:

None

Private:

None

 

 

ccTraceFile::ccTraceFile

ccTraceFile();

Return Value:

None

Arguments:

None

Remarks:

Default Constructor - 
   Will set default trace file name to ".\ccTrace.trc".
   Will set the MaxFileSize to 20 kiloBytes.

Example:

ccTraceFile oTraceFile;

 

ccTraceFile::enableLogging

E_ccErrRet enableLogging( BOOL abEnable = TRUE, 

                          BOOL abAppend = FALSE );

Return Value:

E_ccErrRet

Returns CCSUCCEDED if the logging was started with out any errors.
Returns CCFAILED if the logging didn't start. The error message will be reported by ccError::error.

Arguments:

abEnable

True if the logging should be enabled and False if the logging should be disabled.

abAppend

True if  the trace messages should be appended to an eventually already existing logfile. False if the eventually already existing logFile should be cleared.

Remarks:

This member will open the trace file and turn on the trace, or close the trace file and turn off the trace. 

A new file will be created if the trace file doesn't exist. If the trace file exist, it can be truncated or opened for appending.

If the filename isn't set, the name ".\ccTrace.trc" will be used.

Example:

ccTraceFile oTraceFile;
oTraceFile.enableLogging( );

...

oTraceFile.enableLogging( FALSE );

 

ccTraceFile::setFileName

void setFileName( CString asFileName );

Return Value:

None

Arguments:

asFileName

The new name for the trace file.

Remarks:

Sets the name of the traceFile.

If the traceing is on, it will be turned off and then turned on again with the new filename. And new messages will be appened to the end of the file.

Example:

ccTraceFile oTraceFile;
oTraceFile.setFilename( "ccTrace.trc" );

 

ccTraceFile::browseTraceFile

void browseTraceFile();

Return Value:

None

Arguments:

None

Remarks:

Opening a save as dialog, from which the user can select the trace file name. The new name will be set with the setFileName member.

Example:

ccTraceFile oTraceFile;
CString lsTraceFile = oTraceFile.browseTraceFile( );

 

ccTraceFile::getFileName

CString getFileName();

Return Value:

CString

The current name of the tracefile

Arguments:

None

Remarks:

Get the name of the traceFile.

Example:

ccTraceFile oTraceFile;
CString lsTraceFile = oTraceFile.getFileName( );

 

ccTraceFile::addMessage

void addMessage( CString asMessage );

Return Value:

None

Arguments:

CString

The text that will be added to the traceFile.

Remarks:

This member adds a message to the traceFile. If the traceFile is closed the member will just throw away the message. The message format will be the following "12/24/99 11:23:59 This is the message."

This member will also check if the log file is full, and if it is close the file and show an error message.

Example:

ccTraceFile oTraceFile;
oTraceFile.enableLogging( );

oTraceFile.addMessage( "Test Message" );

oTraceFile.enableLogging( FALSE );

 

ccTraceFile::view

void view();

Return Value:

None

Arguments:

None

Remarks:

This will disable the tracing and display the traceFile in notepad.

Example:

ccTraceFile oTraceFile;
oTraceFile.enableLogging( );

oTraceFile.addMessage( "Test Message" );

oTraceFile.view();

 

ccTraceFile::clear

void clear();

Return Value:

None

Arguments:

None

Remarks:

This will clear the trace file. It it was opened it will be remain opened. If it was closed it will remain closed.

Example:

ccTraceFile oTraceFile;
oTraceFile.enableLogging( );

oTraceFile.addMessage( "Test Message" );

oTraceFile.clear();

oTraceFile.view();

 

ccTraceFile::isTraceing

BOOL isTraceing( );

Return Value:

BOOL

True if the tracing is enabled and False if it's disabled.

Arguments:

None

Remarks:

This member will tell if the file logging is enabled.

Example:

ccTraceFile oTraceFile;
oTraceFile.enableLogging( );

if ( oTraceFile.istraceing() )
{
   ...
}

 

ccTraceFile::setLogSize

void setLogSize( int aiLogSize );

Return Value:

None

Arguments:

int

The size in kilo bytes the file can reach. If this number is execed it will show an error message and increase the size of the log file by one kilo byte. If aiLogSize is -1 the log file will have unlimted size.

Remarks:

The size of the log file in kilo bytes.

Example:

ccTraceFile oTraceFile;
oTraceFile.setLogSize( 10 );

 

ccTraceFile::getLogSize  

int getLogSize( );

Return Value:

int

The current max size of the log file.

Arguments:

None

Remarks:

This member will return the max size of the log file in kilo bytes.

Example:

ccTraceFile oTraceFile;
int liLogSize = oTraceFile.getLogSize( );