Add some mechanisms to add log support to Vivy.
LogSink
is an object that will collect all the logs and emit them to a file, stderr
, or in a Qt widgetLogger
is the object used to create log message and submit them to the sinkLogMessage
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 like auto 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.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:
// ...
};
VivyConsoleDispatcher
-> a dock widget with the MainWindow
, like the console with VSCode or EclipseLogDispatcherThread
-> flush at regular intervals the LogSink
Also merge dependent MR with this one to uniformize the logging process