Skip to content

Commit

Permalink
fix: Logger compatibility with WIndows and QT 6
Browse files Browse the repository at this point in the history
  • Loading branch information
pktiuk committed May 31, 2024
1 parent 50bce15 commit 4f9f917
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
#include <QMetaObject>
#include <QTime>

// only for QT 6
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include <QStringConverter>
#endif
#include <chrono>
#include <thread>

Expand Down Expand Up @@ -183,7 +187,11 @@ void Logger::setCurrentLogFile(QString filename)
}
instance->outFileStream.setDevice(&instance->outputFile);
#if defined(Q_OS_WIN)
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
instance->outFileStream.setEncoding(QStringConverter::Utf8);
#else
instance->outFileStream.setCodec("UTF-8"); // to properly print special characters in files
#endif
#endif
instance->setCurrentStream(&instance->outFileStream);
}
Expand Down

0 comments on commit 4f9f917

Please sign in to comment.