我有一个问题,我在应用程序中记录了一些信息,例如请求、消息、响应,并且在这部分代码中发生了这种情况。我的目标是在应用程序运行时查看日志文件,这似乎现在不会发生,因此用户必须退出应用程序然后转到公用文件夹才能查看日志。如果需要,我可以提供更多信息。
void LogClass::log(const char* pcszComponent, const char* pcszLevel, const CF1String& title, const CF1String& message)
{
m_guard.lock();
QByteArray byteArray(QTime::currentTime().toString("HH:mm:ss.zzz").toAscii());
XXString logMessage = XXFormatString("[%s] [%7s] [%4s] [%08X] [%s] [%s]\r\n", byteArray.constData(), pcszLevel, pcszComponent, QThread::currentThreadId(), title.c_str(), message.c_str());
if (!m_pLogFile) {
createLogFile();
}
if (m_pLogFile) {
fputs(logMessage.c_str(), m_pLogFile);
fflush(m_pLogFile);
}
m_guard.unlock();
}
提前致谢。