NclLog Class Reference

#include <NclLog.h>

Collaboration diagram for NclLog:

Collaboration graph
[legend]
List of all members.

Detailed Description

requirements
GNU C++ Compatible Compiler or MS Compiler
win2k or later
WxWidgets 2.6
Version:
1.0 first version
Date:
09-08-2005
Author:
kamp
license
This code is absolutely free to use and modify. The code is provided "as is" with no expressed or implied warranty. The author accepts no liability if it causes any damage to your computer, causes your pet to fall ill, increases baldness or makes your car start emitting strange noises when you start it up. This code has no bugs, just undocumented features!

Todo:

Bug:

Definition at line 35 of file NclLog.h.

Public Member Functions

 NclLog (void)
 NclLog (wxString name)
virtual ~NclLog (void)
void Clear ()
bool Line (wxString message)
bool Line (wxString format, wxString message)
bool Line (wxString format, long number)
bool Line (wxString format, long number1, long number2)
void Creation (wxString name, NclBase *base)
void Destruction (wxString name, NclBase *base)

Private Member Functions

void Open ()
wxString DateTime (wxString message)

Private Attributes

wxString logFileName
FILE * logFilePtr


Constructor & Destructor Documentation

NclLog::NclLog void   ) 
 

Use the default name for the log file. The default name is NClip.log if the current directory.

Parameters:
void 
Returns:

Definition at line 8 of file NclLog.cpp.

References Open().

00009 {
00010   logFileName= "NClip.log";
00011   Open( );
00012 }

NclLog::NclLog wxString  name  ) 
 

Provide the name of the log file.

Parameters:
name 
Returns:

Definition at line 14 of file NclLog.cpp.

References Open().

00015 {
00016   logFileName = name;
00017   Open( );
00018 }

NclLog::~NclLog void   )  [virtual]
 

Close the log.

Parameters:
void 
Returns:

Definition at line 20 of file NclLog.cpp.

References Line().

00021 {
00022   wxString m = "--------------------------------------------";
00023   m.Append( "Close the log file." );
00024   Line( m );
00025   fclose ( logFilePtr );
00026 }


Member Function Documentation

void NclLog::Clear  ) 
 

Clear the log

Definition at line 36 of file NclLog.cpp.

References Line().

00037 {
00038   fclose ( logFilePtr );
00039   logFilePtr = fopen ( logFileName, "w" );
00040   wxString m = "The log file was cleared.";
00041   Line( m );
00042 }

void NclLog::Creation wxString  name,
NclBase *  base
 

Log the creation of an object.

Parameters:
name 
*base 

Definition at line 104 of file NclLog.cpp.

References NclBase::GetSerialNumberString(), and Line().

Referenced by NclSession::Init(), NclCanvas::Init(), Mdo::Mdo(), NclBase::NclBase(), NclFileParser::NclFileParser(), NclFrame::NclFrame(), NclGridFromText::NclGridFromText(), NclSplitterWindow::NclSplitterWindow(), and NclTemplateClass::NclTemplateClass().

00105 {
00106   wxString m = "#";
00107   m.Append ( " " );
00108   m.Append( base->GetSerialNumberString());
00109   m.Append( " " );
00110   m.Append ( name );
00111   m.Append( " Created.");
00112   Line( m );
00113 }

wxString NclLog::DateTime wxString  message  )  [private]
 

Return the Date and Time as a wxString.

Parameters:
message 
Returns:

Definition at line 89 of file NclLog.cpp.

Referenced by Line().

00090 {
00091   // Add the current date and time to the wxString.
00092   wxString m = "";
00093   time_t rawtime;
00094   struct tm * timeinfo;
00095   time ( &rawtime );
00096   timeinfo = localtime ( &rawtime );
00097   wxString dt = asctime( timeinfo );
00098   m.Append(dt.Left( (dt.Len()-1)));
00099   m.Append ( " " );
00100   m.Append( message );
00101   return m;
00102 }

void NclLog::Destruction wxString  name,
NclBase *  base
 

Log the destruction of an object.

Parameters:
name 
*base 

Definition at line 115 of file NclLog.cpp.

References NclBase::GetSerialNumberString(), and Line().

Referenced by NclSession::Clean(), NclFrame::Clean(), Mdo::~Mdo(), NclBase::~NclBase(), NclFileParser::~NclFileParser(), NclGridFromText::~NclGridFromText(), and NclTemplateClass::~NclTemplateClass().

00116 {
00117   wxString m = "#";
00118   m.Append ( " " );
00119   m.Append( base->GetSerialNumberString());
00120   m.Append ( " " );
00121   m.Append ( name );
00122   m.Append( " Destroyed.");
00123   Line( m );
00124 }

bool NclLog::Line wxString  format,
long  number1,
long  number2
 

Add two longs to the log, using the given format.

Parameters:
format 
message 
Returns:

Definition at line 78 of file NclLog.cpp.

References DateTime().

00079 {
00080   wxString m = DateTime( mIn );
00081   bool rv = true;
00082   int rl = fprintf( logFilePtr, "%s %d %d\n", m.c_str(), number1, number2 );
00083   if ( rl < 0 ) {
00084     rv = false;
00085   }
00086   return rv;
00087 }

bool NclLog::Line wxString  format,
long  number
 

Add a long to the log, using the given format.

Parameters:
format 
message 
Returns:

Definition at line 67 of file NclLog.cpp.

References DateTime().

00068 {
00069   wxString m = DateTime( mIn );
00070   bool rv = true;
00071   int rl = fprintf( logFilePtr, "%s %d\n", m.c_str(), number );
00072   if ( rl < 0 ) {
00073     rv = false;
00074   }
00075   return rv;
00076 }

bool NclLog::Line wxString  format,
wxString  message
 

Add a line to the log, using the given format.

Parameters:
format 
message 
Returns:

Definition at line 56 of file NclLog.cpp.

References DateTime().

00057 {
00058   wxString m = DateTime( mIn );
00059   bool rv = true;
00060   int rl = fprintf( logFilePtr, format, m.c_str() );
00061   if ( rl < 0 ) {
00062     rv = false;
00063   }
00064   return rv;
00065 }

bool NclLog::Line wxString  message  ) 
 

Add a line as a string to the log.

Parameters:
message 
Returns:

Definition at line 45 of file NclLog.cpp.

References DateTime().

Referenced by Clear(), NclSession::Close(), Creation(), Destruction(), Open(), NclFileManager::OpenGraphicFile(), NclFileManager::OpenTextFile(), NclFileManager::OpenXmlFile(), NclSession::SaveInCache(), NclSession::SaveInPlace(), NclGridFromText::SetNolColHeader(), NclGridFromText::SetNolHeader(), NclGridFromText::SetNolTrailer(), and ~NclLog().

00046 {
00047   wxString m = DateTime( mIn );
00048   bool rv = true;
00049   int rl = fprintf( logFilePtr, "%s\n", m.c_str() );
00050   if ( rl < 0 ) {
00051     rv = false;
00052   }
00053   return rv;
00054 }

void NclLog::Open  )  [private]
 

Open the log. This also writes an opening declaration to the log along with the date and time.

Definition at line 28 of file NclLog.cpp.

References Line().

Referenced by NclLog().

00029 {
00030   logFilePtr = fopen( logFileName, "a" );
00031   wxString m = "++++++++++++++++++++++++++++++++++++++++++++";
00032   m.Append( "Open the log file." );
00033   Line( m );
00034 }


Generated on Wed Sep 28 11:10:50 2005 for NClip by doxygen 1.3.1 using KingsTools