Add clean logs support + dependent MR
Description
Add some mechanisms to add log support to Vivy.
- A
LogSink
is an object that will collect all the logs and emit them to a file,stderr
, or in a Qt widget - A
Logger
is the object used to create log message and submit them to the sink - A
LogMessage
is a message, a line of log. You should not create it yourself, but use the macros or defined methods. They are submitted on destruction, so don't try things likeauto msg = VIVY_LOG_WARN(appLog); msg << "toto";
unless you know what you are doing. If you don't pay attention, you might get log messages in a different order than what you originally wanted.
Example
Here is a small demo:
// Custom sink
VIVY_DCL_LOG_SINK(logSink) // Declare a Sink
std::shared_ptr<Logger> scriptLog = VIVY_GET_LOGGER(mySink, SCRIPT); // Custom logger
VIVY_LOG_WARN(scriptLog) << "This is" << ' ' << "very usefull!"; // Use the custom logger
// With the vivyApp's sink
class Object {
// Add a logger to the sink and add log methods to the object
VIVY_APP_LOGGABLE_OBJECT(Object, logger)
public:
// ...
};
TODO List
-
Create and use the API -
The simple stderr dispatcher -
The VivyConsoleDispatcher
-> a dock widget with theMainWindow
, like the console with VSCode or Eclipse -
Create the LogDispatcherThread
-> flush at regular intervals theLogSink
Also merge dependent MR with this one to uniformize the logging process
Modification effectuée par Kubat
Rapports de requête de fusion
Activité
Veuillez vous inscrire ou vous connecter pour répondre