mirror of
https://gitlab.com/spaceti-app/integrations/common/server-sdk.git
synced 2026-07-12 14:20:50 +02:00
disabled color output for Windows
This commit is contained in:
parent
5025a68891
commit
38a7da300d
@ -14,7 +14,11 @@ Q_LOGGING_CATEGORY(sdkdb, "sdk.db");
|
|||||||
namespace serversdk {
|
namespace serversdk {
|
||||||
|
|
||||||
Logger* Logger::sConsumer = nullptr;
|
Logger* Logger::sConsumer = nullptr;
|
||||||
//bool Logger::sShowFunction = false;
|
#ifdef Q_OS_UNIX
|
||||||
|
bool Logger::mColorOutput = true;
|
||||||
|
#else
|
||||||
|
bool Logger::mColorOutput = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void Logger::setConsumer(Logger *consumer)
|
void Logger::setConsumer(Logger *consumer)
|
||||||
@ -25,6 +29,7 @@ void Logger::setConsumer(Logger *consumer)
|
|||||||
Logger::Logger(QObject *parent) : QObject(parent)
|
Logger::Logger(QObject *parent) : QObject(parent)
|
||||||
{
|
{
|
||||||
qRegisterMetaType<LoggerMessage>();
|
qRegisterMetaType<LoggerMessage>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<LoggerMessage> Logger::getNewMessages(int currentCount)
|
QList<LoggerMessage> Logger::getNewMessages(int currentCount)
|
||||||
@ -50,6 +55,11 @@ QString Logger::toColor(const QString &color, const QString &text)
|
|||||||
return color + text + "\033[0m";
|
return color + text + "\033[0m";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Logger::setColorOutput(bool colorOutput)
|
||||||
|
{
|
||||||
|
mColorOutput = colorOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Logger::outputMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
void Logger::outputMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
{
|
{
|
||||||
@ -94,9 +104,11 @@ void Logger::outputMessage(QtMsgType type, const QMessageLogContext &context, co
|
|||||||
|
|
||||||
QDateTime now = QDateTime::currentDateTime();
|
QDateTime now = QDateTime::currentDateTime();
|
||||||
|
|
||||||
|
const QString textTypeUni = mColorOutput ? colorTextType : textType;
|
||||||
|
|
||||||
text = QStringLiteral("[%1 %2 %3] %4") // [ %3:%4 | %5 | %6 ]")
|
text = QStringLiteral("[%1 %2 %3] %4") // [ %3:%4 | %5 | %6 ]")
|
||||||
.arg(now.toString("dd-MM-yyyy hh:mm:ss.z"))
|
.arg(now.toString("dd-MM-yyyy hh:mm:ss.z"))
|
||||||
.arg(colorTextType)
|
.arg(textTypeUni)
|
||||||
.arg(context.category)
|
.arg(context.category)
|
||||||
.arg(msg);
|
.arg(msg);
|
||||||
|
|
||||||
|
|||||||
@ -97,6 +97,8 @@ public:
|
|||||||
|
|
||||||
static QString toColor(const QString &color, const QString &text);
|
static QString toColor(const QString &color, const QString &text);
|
||||||
|
|
||||||
|
/** I will enable color output for terminal ( linux only ) */
|
||||||
|
void setColorOutput(bool colorOutput);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void messageReceived(const serversdk::LoggerMessage &message);
|
void messageReceived(const serversdk::LoggerMessage &message);
|
||||||
@ -104,6 +106,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
QList<LoggerMessage> mLogMessages; //!< Test
|
QList<LoggerMessage> mLogMessages; //!< Test
|
||||||
QMutex mMutex;
|
QMutex mMutex;
|
||||||
|
static bool mColorOutput;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user