-
Notifications
You must be signed in to change notification settings - Fork 0
Logging
Logging is based on the Logger library. Visit it to learn it in detail.
The simplest console is the native console view. It's just a black console window.
To be able to receive log messages, a instance of the console view must be created.
Call this code in the constructor of your MainWindow
or the main.cpp
.
Log::UI::NativeConsoleView::createStaticInstance();
Log::UI::NativeConsoleView::getStaticInstance()->show();
You can add a Qt Widget based console, for example:
Log::UI::QConsoleView::createStaticInstance();
Log::UI::QConsoleView::getStaticInstance()->show();
Log::UI::QTreeConsoleView::createStaticInstance();
Log::UI::QTreeConsoleView::getStaticInstance()->show();
If you want to stream the log messages to a file, you can create a FilePlotter
instance.
As long as this instance exists, it plots all messages to the file.
Log::FilePlotter plotter("logfile.log");
By default if you call the log methodes on a GameObject: this->log("MessageText")
.
It will be in the context of the Scene the object is in.
But a custom logger instance can be created for the GameObject. To do so, call obj->createLogger()
.
That function creates a logger instance for the GameObject. Every child object will now log to that logger.
The logger has the same name as the Object.
If you create custom loggers for all GameObjects within a object tree, than the loggers will be arranged to fit the same tree structure.
This is usefull if the Log::UI::QTreeConsoleView
is used.
For easy debugging, you can print messages to the console.
Each Component contains a interface to the logging system of the Scene.
Logging is only available if the component is in a GamaObject that is contained within a Scene.
Inside your Component, call: this->log("MessageText")