1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2015 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 // contains all debug features
24 #include <nel/misc/debug.h>
25 #include <nel/misc/report.h>
29 // hit always ignore to surpress this error for the duration of the program
30 nlassert(false && "hit always ignore");
33 int main(int /* argc */, char ** /* argv */)
35 // all debug functions have different behaviors in debug and in release mode.
36 // in general, in debug mode, all debug functions are active, they display
37 // what happens and some break the program to debug it. In release mode, they often
38 // do nothing to increase the execution speed.
41 // this function initializes debug functions. it adds displayers into the debug
43 // in debug mode, all debug functions display on the std output.
44 // in release mode, this function does nothing by default. you have to add a displayer
45 // manually, or put true in the parameter to say to the function that you want it to
46 // add the default displayers
47 NLMISC::createDebug();
49 // enable the crash report tool
50 NLMISC::INelContext::getInstance().setWindowedApplication(true);
51 NLMISC::setReportPostUrl("http://ryzomcore.org/crash_report/");
53 // display debug information, that will be skipped in release mode.
54 nldebug("nldebug() %d", 1);
57 nlinfo("nlinfo() %d", 2);
59 // when something not normal, but that the program can manage, occurs, call nlwarning()
60 nlwarning("nlwarning() %d", 3);
62 // nlassert() is like assert but do more powerful things. in release mode, the test is
63 // not executed and nothing will happen. (Press F5 in Visual C++ to continue the execution)
64 nlassert(true == false);
66 // in a switch case or when you want that the program never executes a part of code, use stop.
67 // in release, nlstop does nothing. in debug mode,
68 // if the code reaches the nlstop, a breakpoint will be set. (In Visual C++ press F5 to continue)
71 // when the program failed, call nlerror(), it displays the message and throws a EFatalError to
72 // exit the program. don't forget to put a try/catch block everywhere an nlerror could
73 // occurs. (In Visual C++ press F5 to continue)
76 nlerror("nlerror() %d", 4);
78 catch (const NLMISC::EFatalError
&)
81 nlinfo("nlerror() generated an EFatalError exception, just ignore it");
84 // keep repeating the same error
85 for (int i
= 0; i
< 32; ++i
)
88 printf("\nPress <return> to exit\n");