--- a/src/basics.h Mon Jun 20 16:59:09 2022 +0300 +++ b/src/basics.h Mon Jun 20 17:27:30 2022 +0300 @@ -26,6 +26,7 @@ #include <set> #include <type_traits> #include <QDataStream> +#include <QDateTime> #include <QDebug> #include <QObject> #include <QPointF> @@ -295,3 +296,25 @@ template<typename T> using Graph = std::deque<GraphEdge<T>>; + +struct Message +{ + QDateTime time; + enum { Info, Warning, Error } type; + QString text; +}; + +inline Message logInfo(const QString text) +{ + return Message{.time = QDateTime::currentDateTime(), .type = Message::Info, .text = text}; +} + +inline Message logWarning(const QString text) +{ + return Message{.time = QDateTime::currentDateTime(), .type = Message::Warning, .text = text}; +} + +inline Message logError(const QString text) +{ + return Message{.time = QDateTime::currentDateTime(), .type = Message::Error, .text = text}; +}