Skip to content

Commit e93b380

Browse files
committed
Windows - Log to Debug Output window
1 parent d6f4c9f commit e93b380

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

libsrc/utils/Logger.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,20 @@ void Logger::write(const Logger::T_LOG_MESSAGE & message)
151151
name.resize(MAX_IDENTIFICATION_LENGTH, ' ');
152152

153153
const QDateTime timestamp = QDateTime::fromMSecsSinceEpoch(message.utime);
154-
std::cout << QString("%1 %2 : <%3> %4%5")
155-
.arg(timestamp.toString(Qt::ISODateWithMs))
156-
.arg(name)
157-
.arg(LogLevelStrings[message.level])
158-
.arg(location)
159-
.arg(message.message)
160-
.toStdString()
161-
<< std::endl;
154+
QString msg = timestamp.toString(Qt::ISODateWithMs)
155+
% " " % name
156+
% " : <" % LogLevelStrings[message.level]
157+
% "> " % location
158+
% message.message % "\n";
159+
160+
#ifdef _WIN32
161+
if (IsDebuggerPresent())
162+
{
163+
OutputDebugStringA(QSTRING_CSTR(msg));
164+
}
165+
else
166+
#endif
167+
std::cout << msg.toStdString();
162168

163169
emit newLogMessage(message);
164170
}

0 commit comments

Comments
 (0)