#include <basiclog.h>
Inheritance diagram for BasicLog:
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 |
BasicLog is a class for logging debug-information to a file Usually used as an inherited class
BasicLog::BasicLog | ( | const char * | name, | |
BasicObject * | parent, | |||
const char * | filename | |||
) |
Create a BasicLog-variable, specifying the filename of the log-file
filename | the path to the file to write to, or NULL, if you need no loggings or want to init it later with "initLogFile" |
DECLSPEC BasicLog::BasicLog | ( | const char * | name, | |
BasicObject * | parent, | |||
std::ostream * | strm = &std::cout | |||
) |
Create a BasicLog-variable, specifying the stream for logging
strm | the stream, used for logging; if no param specified, the standard output (std::cout) is used |
BasicLog::BasicLog | ( | TiXmlElement * | el, | |
BasicObject * | p | |||
) |
Constructor, used with XML data.
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 |
void BasicLog::logLine | ( | const char * | ln | ) |
writes a string in a new line to the log-file
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
ln | string to log |
void BasicLog::logLevel | ( | const char * | str | ) |
writes a string structured to the log-file
str | string to log |
void BasicLog::logLevelLine | ( | const char * | ln | ) |
writes a string structured in a new line to the log-file
ln | string to log |
void BasicLog::logEnd | ( | const char * | ln | ) |
writes a string structured to the log-file, incrementing the number of forward-spaces
ln | string to log |
bool BasicLog::setDebug | ( | bool | dodebug | ) |
enable/disable logging; if no logfile was specified before, "debug.log" will be opened
dodebug | true to enable / false to disable logging |
DECLSPEC bool BasicLog::getDebug | ( | ) | [inline] |
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)
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
fn | path to the log file |
DECLSPEC void BasicLog::initLogStream | ( | std::ostream * | strm | ) | [protected] |
Uses the specified stream for logging. Logging is always turned on after calling this function.
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.
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