Skip to content
Extraits de code Groupes Projets
Vérifiée Valider de9dd501 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

LOG: Add a way to get the sink from the VivyApplication and add more...

LOG: Add a way to get the sink from the VivyApplication and add more possibilities for logging things
parent 0a4a83ca
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!21Add clean logs support + dependent MR
Ce commit fait partie de la requête de fusion !21. Les commentaires créés ici seront créés dans le contexte de cette requête de fusion.
...@@ -141,6 +141,17 @@ LogMessage::operator<<(const char *str) noexcept ...@@ -141,6 +141,17 @@ LogMessage::operator<<(const char *str) noexcept
return *this; return *this;
} }
LogMessage &
LogMessage::operator<<(const char c) noexcept
{
if (indexInArray < messageBufferLength - 1) {
textBuffer[indexInArray] = c;
++indexInArray;
textBuffer[indexInArray] = '\0';
}
return *this;
}
const std::string_view const std::string_view
LogMessage::getTextBuffer() const noexcept LogMessage::getTextBuffer() const noexcept
{ {
......
...@@ -3,15 +3,15 @@ ...@@ -3,15 +3,15 @@
#include "Utils.hh" #include "Utils.hh"
// Create a logger with a category // Create a logger with a category
#define VIVY_GET_LOGGER(sink, cat) std::make_shared<Logger>(sink.get(), cat) #define VIVY_GET_LOGGER(sink, cat) std::make_shared<Logger>((sink).get(), std::string_view{ #cat })
// Log something in a logger // Log something in a logger
#define VIVY_LOG_WITH_LEVEL(log, level) log->logEvent(__FILE__, __func__, __LINE__, level) #define VIVY_LOG_WITH_LEVEL(log, level) log->logEvent(__FILE__, __func__, __LINE__, level)
#define VIVY_LOG_WARN(log) VIVY_LOG_WITH_LEVEL(log, LogLevel::Warning) #define VIVY_LOG_WARN(log) VIVY_LOG_WITH_LEVEL(log, Vivy::LogLevel::Warning)
#define VIVY_LOG_DEBUG(log) VIVY_LOG_WITH_LEVEL(log, LogLevel::Debug) #define VIVY_LOG_DEBUG(log) VIVY_LOG_WITH_LEVEL(log, Vivy::LogLevel::Debug)
#define VIVY_LOG_INFO(log) VIVY_LOG_WITH_LEVEL(log, LogLevel::Info) #define VIVY_LOG_INFO(log) VIVY_LOG_WITH_LEVEL(log, Vivy::LogLevel::Info)
#define VIVY_LOG_ERR(log) VIVY_LOG_WITH_LEVEL(log, LogLevel::Error) #define VIVY_LOG_ERR(log) VIVY_LOG_WITH_LEVEL(log, Vivy::LogLevel::Error)
#define VIVY_LOG_FATAL(log) VIVY_LOG_WITH_LEVEL(log, LogLevel::Critical) #define VIVY_LOG_FATAL(log) VIVY_LOG_WITH_LEVEL(log, Vivy::LogLevel::Critical)
// Declare a sink, with the utility function/method `flushLogSink`. This is // Declare a sink, with the utility function/method `flushLogSink`. This is
// intended to be used in an object to not polluate namespaces. // intended to be used in an object to not polluate namespaces.
...@@ -36,10 +36,15 @@ ...@@ -36,10 +36,15 @@
LogMessage logInfo() const noexcept { return VIVY_LOG_INFO(logger); } \ LogMessage logInfo() const noexcept { return VIVY_LOG_INFO(logger); } \
LogMessage logDebug() const noexcept { return VIVY_LOG_DEBUG(logger); } LogMessage logDebug() const noexcept { return VIVY_LOG_DEBUG(logger); }
#define VIVY_LOG_CTOR(classname) logDebug() << #classname "::CTOR "
#define VIVY_LOG_DTOR(classname) logDebug() << #classname "::DTOR "
// Install logger, use the global LogSink
#define VIVY_APP_LOGGABLE_OBJECT(name, logger) \
VIVY_LOGGABLE_OBJECT(vivyApp->getLogSink(), name, logger)
namespace Vivy namespace Vivy
{ {
class VivyApplication;
class VivyCli;
class LogSinkDispatcher; class LogSinkDispatcher;
class LogSink; class LogSink;
class Logger; class Logger;
...@@ -156,6 +161,7 @@ public: ...@@ -156,6 +161,7 @@ public:
LogMessage &operator<<(const std::string &) noexcept; LogMessage &operator<<(const std::string &) noexcept;
LogMessage &operator<<(const QString &) noexcept; LogMessage &operator<<(const QString &) noexcept;
LogMessage &operator<<(const char *) noexcept; LogMessage &operator<<(const char *) noexcept;
LogMessage &operator<<(const char) noexcept;
LogMessage &operator<<(const int) noexcept; LogMessage &operator<<(const int) noexcept;
LogMessage &operator<<(const long) noexcept; LogMessage &operator<<(const long) noexcept;
}; };
......
...@@ -251,16 +251,4 @@ enum class VideoDocumentType : quint64 { ...@@ -251,16 +251,4 @@ enum class VideoDocumentType : quint64 {
// Ass document types // Ass document types
enum class AssDocumentType : quint64 { ASS = Utils::toUnderlying(Utils::DocumentType::ASS) }; enum class AssDocumentType : quint64 { ASS = Utils::toUnderlying(Utils::DocumentType::ASS) };
}
class QMenu;
class QAction;
class QTabWidget;
class QGraphicsPixmapItem;
namespace Vivy
{
class VivyApplication;
class MainWindow;
} }
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
#error "This is a C++ header" #error "This is a C++ header"
#endif #endif
#define vivyApp static_cast<VivyApplication *>(QApplication::instance()) #define vivyApp (dynamic_cast<::Vivy::VivyApplication *>(VivyApplication::instance()))
#define currentVivyDocument() dynamic_cast<VivyDocument *>(vivyApp->getCurrentDocument()) #define currentVivyDocument() dynamic_cast<::Vivy::VivyDocument *>(vivyApp->getCurrentDocument())
#define currentScriptDocument dynamic_cast<ScriptDocument *>(vivyApp->getCurrentDocument()) #define currentScriptDocument dynamic_cast<::Vivy::ScriptDocument *>(vivyApp->getCurrentDocument())
// Only support dark theme for now // Only support dark theme for now
#define VIVY_ICON_APP ":icons/vivy.png" #define VIVY_ICON_APP ":icons/vivy.png"
...@@ -43,7 +43,7 @@ class VivyApplication : public QApplication { ...@@ -43,7 +43,7 @@ class VivyApplication : public QApplication {
Q_OBJECT Q_OBJECT
VIVY_DCL_LOG_SINK(logSink) VIVY_DCL_LOG_SINK(logSink)
VIVY_DCL_LOG_DISPATCH(logSink, stderrLogDispathcer, StderrLogSinkDispatcher) VIVY_DCL_LOG_DISPATCH(logSink, stderrLogDispathcer, StderrLogSinkDispatcher)
VIVY_LOGGABLE_OBJECT(logSink, std::string_view("APPLICATION"), logger) VIVY_LOGGABLE_OBJECT(logSink, APPLICATION, logger)
public: public:
VivyDocumentStore documentStore{}; VivyDocumentStore documentStore{};
...@@ -83,6 +83,8 @@ public: ...@@ -83,6 +83,8 @@ public:
void setUseFakeVimEditor(bool) noexcept; void setUseFakeVimEditor(bool) noexcept;
void setTheme(Theme) noexcept; void setTheme(Theme) noexcept;
std::shared_ptr<LogSink> getLogSink() noexcept { return logSink; }
}; };
} }
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter