I have about 1.5 year of experience with Irrlich ( I think that I started with 1.4 version ^^ ) but I never tried something complicated with Irrlich ( in fact I was but... other people have quit because they saw how much there is work to be done.. so I was forced to do little experiments due lack of man power ).
This piece of code is should have been used in my first serious project http://sourceforge.net/projects/jaelc/ but unfortunately after about 8-9 month project leader had to quit due lack of free time. And soon project got freeze status. And few months ago I started to work on game ( to gain more experience in both c++ and Irrlich ) using Irrlich and it was time to implement some kind of log system. And I remembered that I had one... ( And since this it's part of open source project, I don't take credits for all source files. Read info's in them for more details. ) so I did few cleanups here and there and... behold.
This is simple log writer and viewer (and displays some system info). You can sort logs by namespaces, search function, displays function, file, line and time since app started for given log. To view logs just run _JavascriptViewer.html from logs directory. All files are under GNU General Public License version 3.
You must define in file namespace ( category ) that class belongs to.
There are few namespaces as an example:
default
Main
AI
Scripting
Engine
Loading
UI
Vars
See ComplexXSLT.xsl for detailed explanation.
You will also notice "any" namespace in _JavascriptViewer.html, it's not regular namespace it just will show all logs from all namespaces.
You can modify all namespaces ( not recomended to change "any" namespace from obvious reason ) in _JavascriptViewer.html file.
From archive unpack logs directory to your working directory and source files to where ever you like.
As you noticed by now, I am terrible at explaining so let's just jump to short example of usage:
Code: Select all
#include "LogFile.h"
#define __NAMESPACE__ "Engine"
int _tmain(int argc, _TCHAR* argv[])
{
XLOG_0(__FUNCTION__, LOG_COMMENT, L"I am happy comment :)");
XLOG_1(__FUNCTION__, LOG_MESSAGE, L"I am happy message :)");
XLOG_2(__FUNCTION__, LOG_EVENT, L"I am happy event :)");
XLOG_3(__FUNCTION__, LOG_ERROR, L"I am not so happy error :)");
XLOG_4(__FUNCTION__, LOG_WARNING, L"I am happy warning :)");
XLOG_4(__FUNCTION__, LOG_DEBUG, L"I am happy debug message :)");
return 0;
}
This is how this example looks when you run _JavascriptViewer.html Example ( click on picture to enlarge )
Enums LOG_ERROR, LOG_WARNING, LOG_COMMENT, LOG_EVENT, LOG_DEBUG, LOG_MESSAGE are categories for log messages.
In MSVC macro __FUNCTION__ returns function name as a string, I am not sure how other compilers handle this, in case that
__FUNCTION__ don't work on your compiler just swap it with function name.
Explanation for XLOG levels
XLOG_0 (level 0) = always shown: use only for special purpose
XLOG_1 (level 1) = always shown: critical errors
XLOG_2 (level 2) = non-critical errors
XLOG_3 (level 3) = warnings
XLOG_4 (level 4) = comments, debugs, messages
By default if application is compiled in debug mode all log levels will shown and in release build only 1 and 0 level log will be shown. You can change that by modifying ub_DebugLevel in CLogFile::CLogFile() in LogFile.cpp
It's intend for windows OS so I doubt that it will work under Linux without tweaking the code.
If I missed something I am really sorry but it's 8:43 AM and I didn't sleep all night so if you have any questions feel free to
ask.
Download 18 kb
P.S. Sorry for for grammar errors, English is my second language.