diff --git a/debug.cpp b/debug.cpp
index 70b605938..58e6f04ec 100644
--- a/debug.cpp
+++ b/debug.cpp
@@ -34,63 +34,76 @@ QFile debug_file;
QTextStream debug_stream;
void open_debug_file() {
- QDir debug_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
- debug_dir.mkpath(".");
- if (debug_dir.exists()) {
- debug_file.setFileName(debug_dir.path() + "/debug_log");
- if (debug_file.open(QFile::WriteOnly)) {
- debug_stream.setDevice(&debug_file);
- } else {
- qWarning() << "Couldn't open debug log file, debug log will not be saved";
- }
- }
+ QDir debug_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
+ debug_dir.mkpath(".");
+ if (debug_dir.exists()) {
+ debug_file.setFileName(debug_dir.path() + "/debug_log");
+ if (debug_file.open(QFile::WriteOnly)) {
+ debug_stream.setDevice(&debug_file);
+ } else {
+ qWarning() << "Couldn't open debug log file, debug log will not be saved";
+ }
+ }
}
-void close_debug_file() {
- if (debug_file.isOpen()) debug_file.close();
+void close_debug_file()
+{
+ if (debug_file.isOpen()) {
+ debug_file.close();
+ }
}
-void debug_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
- debug_mutex.lock();
- QByteArray localMsg = msg.toLocal8Bit();
- switch (type) {
- case QtDebugMsg:
- fprintf(stderr, "[DEBUG] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
- if (debug_file.isOpen()) debug_stream << QString("[DEBUG] %1 (%2:%3, %4)\n").arg(localMsg.constData(), context.file, QString::number(context.line), context.function);
- debug_info.append(QString("[DEBUG] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function));
- fflush(stderr);
- break;
- case QtInfoMsg:
- fprintf(stderr, "[INFO] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
- if (debug_file.isOpen()) debug_stream << QString("[INFO] %1 (%2:%3, %4)\n").arg(localMsg.constData(), context.file, QString::number(context.line), context.function);
- debug_info.append(QString("[INFO] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function));
- fflush(stderr);
- break;
- case QtWarningMsg:
- fprintf(stderr, "[WARNING] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
- if (debug_file.isOpen()) debug_stream << QString("[WARNING] %1 (%2:%3, %4)\n").arg(localMsg.constData(), context.file, QString::number(context.line), context.function);
- debug_info.append(QString("[WARNING] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function));
- fflush(stderr);
- break;
- case QtCriticalMsg:
- fprintf(stderr, "[ERROR] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
- if (debug_file.isOpen()) debug_stream << QString("[ERROR] %1 (%2:%3, %4)\n").arg(localMsg.constData(), context.file, QString::number(context.line), context.function);
- debug_info.append(QString("[ERROR] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function));
- fflush(stderr);
- break;
- case QtFatalMsg:
- fprintf(stderr, "[FATAL] %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
- if (debug_file.isOpen()) debug_stream << QString("[FATAL] %1 (%2:%3, %4)\n").arg(localMsg.constData(), context.file, QString::number(context.line), context.function);
- debug_info.append(QString("[FATAL] %1 (%2:%3, %4)
").arg(localMsg.constData(), context.file, QString::number(context.line), context.function));
- fflush(stderr);
-// abort();
- }
+void debug_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
+{
+ debug_mutex.lock();
+ const QByteArray localMsg = msg.toLocal8Bit();
+ const QDateTime now = QDateTime::currentDateTime();
+ const QByteArray timeRepr(now.toString(Qt::ISODate).toLocal8Bit());
+ QString msgTag;
+ QString fontColor;
+ switch (type) {
+ case QtDebugMsg:
+ msgTag = "DEBUG";
+ fontColor = "grey";
+ break;
+ case QtInfoMsg:
+ msgTag = "INFO";
+ fontColor = "blue";
+ break;
+ case QtWarningMsg:
+ msgTag = "WARNING";
+ fontColor = "yellow";
+ break;
+ case QtCriticalMsg:
+ msgTag = "ERROR";
+ fontColor = "red";
+ break;
+ case QtFatalMsg:
+ msgTag = "FATAL";
+ fontColor = "red";
+ break;
+ default:
+ fprintf(stderr, "Unknown debug msg type");
+ fflush(stderr);
+ break;
+ }//switch
+
+ fprintf(stderr, "%s [%s] %s (%s:%u, %s)\n", timeRepr.data(), msgTag.toLocal8Bit().constData(), localMsg.data(),
+ context.file, context.line, context.function);
+ if (debug_file.isOpen()) {
+ debug_stream << QString("[%1] %2 (%3:%4, %5)\n")
+ .arg(msgTag, localMsg, context.file, QString::number(context.line), context.function);
+ }
+ debug_info.prepend(QString("[%2] %3 (%4:%5, %6)
")
+ .arg(fontColor, msgTag, localMsg, context.file, QString::number(context.line), context.function));
+ fflush(stderr);
if (Olive::DebugDialog != nullptr && Olive::DebugDialog->isVisible()) {
QMetaObject::invokeMethod(Olive::DebugDialog, "update_log", Qt::QueuedConnection);
- }
- debug_mutex.unlock();
+ }
+ debug_mutex.unlock();
}
-const QString &get_debug_str() {
- return debug_info;
+const QString &get_debug_str()
+{
+ return debug_info;
}
diff --git a/io/previewgenerator.cpp b/io/previewgenerator.cpp
index 20fb69fa0..08a559a83 100644
--- a/io/previewgenerator.cpp
+++ b/io/previewgenerator.cpp
@@ -1,4 +1,4 @@
-/***
+/***
Olive - Non-Linear Video Editor
Copyright (C) 2019 Olive Team
diff --git a/ui/renderfunctions.cpp b/ui/renderfunctions.cpp
index 725b56708..ca99b970a 100644
--- a/ui/renderfunctions.cpp
+++ b/ui/renderfunctions.cpp
@@ -44,7 +44,7 @@
#include "panels/viewer.h"
extern "C" {
- #include
+#include
}
void full_blit() {