BasicLog Class Reference
[Basic classes]

Basic functions for debugging, using a log file. More...

#include <basiclog.h>

Inheritance diagram for BasicLog:

Inheritance graph
[legend]
Collaboration diagram for BasicLog:

Collaboration graph
[legend]
List of all members.

Public Member Functions

DECLSPEC BasicLog (const char *name, BasicObject *parent, const char *filename)
DECLSPEC BasicLog (const char *name, BasicObject *parent, std::ostream *strm=&std::cout)
DECLSPEC BasicLog (TiXmlElement *el, BasicObject *p)
DECLSPEC void logLine (const char *ln)
DECLSPEC void logString (const char *str)
DECLSPEC void logTime ()
DECLSPEC void logBegin (const char *ln)
DECLSPEC void logLevel (const char *str)
DECLSPEC void logLevelLine (const char *ln)
DECLSPEC void logEnd (const char *ln)
DECLSPEC bool setDebug (bool dodebug)
DECLSPEC bool getDebug ()

Static Public Member Functions

static DECLSPEC void logStdOut (const char *s)

Protected Member Functions

DECLSPEC bool initLogFile (const char *fn)
DECLSPEC void initLogStream (std::ostream *strm)
virtual DECLSPEC void onInit ()

Protected Attributes

DECLSPEC bool bAutoLogTime

Classes

struct  Logger

Detailed Description

Basic functions for debugging, using a log file.

BasicLog is a class for logging debug-information to a file Usually used as an inherited class


Constructor & Destructor Documentation

BasicLog::BasicLog ( const char *  name,
BasicObject parent,
const char *  filename 
)

Create a BasicLog-variable, specifying the filename of the log-file

Parameters:
filename the path to the file to write to, or NULL, if you need no loggings or want to init it later with "initLogFile"
See also:
initLogFile

DECLSPEC BasicLog::BasicLog ( const char *  name,
BasicObject parent,
std::ostream *  strm = &std::cout 
)

Create a BasicLog-variable, specifying the stream for logging

Parameters:
strm the stream, used for logging; if no param specified, the standard output (std::cout) is used
See also:
initLogStream

BasicLog::BasicLog ( TiXmlElement el,
BasicObject p 
)

Constructor, used with XML data.

Parameters:
el the XML data, if the attribute "Logfile" is specified, the concerning file will be used for log data; if "Logstream" is specified, a stream is used for logging ("out" or "err"); if LogTimes is specified and set "false", no times are logged
p the parent element, or NULL to take GuiManager::the as parent


Member Function Documentation

void BasicLog::logLine ( const char *  ln  ) 

writes a string in a new line to the log-file

Parameters:
ln the string to log

void BasicLog::logString ( const char *  str  ) 

simply writes a string to the log-file

void BasicLog::logTime (  ) 

writes the time in msecs since SDL initialisation as decimal string to the logfile

void BasicLog::logBegin ( const char *  ln  ) 

writes a string structured to the log-file, incrementing the number of forward-spaces

Parameters:
ln string to log

void BasicLog::logLevel ( const char *  str  ) 

writes a string structured to the log-file

Parameters:
str string to log

void BasicLog::logLevelLine ( const char *  ln  ) 

writes a string structured in a new line to the log-file

Parameters:
ln string to log

void BasicLog::logEnd ( const char *  ln  ) 

writes a string structured to the log-file, incrementing the number of forward-spaces

Parameters:
ln string to log

bool BasicLog::setDebug ( bool  dodebug  ) 

enable/disable logging; if no logfile was specified before, "debug.log" will be opened

Parameters:
dodebug true to enable / false to disable logging
Returns:
true, if logging is now enabled, otherwise false (if no log-file could be opened, then false will be returned)

DECLSPEC bool BasicLog::getDebug (  )  [inline]

Returns:
the current debug-status (bDebug)

void BasicLog::logStdOut ( const char *  s  )  [static]

Prints a string to the standard output and calls flush() to do that immediatelly (even, if the app crashes directly after that)

Parameters:
s the string

bool BasicLog::initLogFile ( const char *  fn  )  [protected]

opens a file for logging. If the file exists, it's content will be cleared, otherwise a new file will be created On success, debugging is turned on

Parameters:
fn path to the log file
Returns:
false, if the file cannot be used, otherwise true

DECLSPEC void BasicLog::initLogStream ( std::ostream *  strm  )  [protected]

Uses the specified stream for logging. Logging is always turned on after calling this function.

Parameters:
strm the stream to use, if NULL

void BasicLog::onInit (  )  [protected, virtual]

Initializes the object's variables by reading data from the XML element. If there were no XML data used for creation, nothing is done. This function calls onInit() of its children recursively (after it has inited itself). It is highly recommended to call BasicObject::onInit(), usually at the end of the onInit() method, when overwriting it in a derived class.

Reimplemented from BasicObject.

Reimplemented in BasicApp, NetThread, WebServer, and XmlApp.


Member Data Documentation

DECLSPEC bool BasicLog::bAutoLogTime [protected]

if bAutoLogTime is true then there will be inserted the current time (msecs since SDL_Init) at every new line


The documentation for this class was generated from the following files:
Generated on Wed May 9 17:36:11 2007 for netrinjo by  doxygen 1.5.1