MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / redirectGlobalDebug

Function redirectGlobalDebug

src/framework/log/frameworklog.cpp:113–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111 }
112
113 void redirectGlobalDebug(QtMsgType type,
114 const QMessageLogContext &context,
115 const QString &msg)
116 {
117 QMutexLocker locker(&mutex);
118 QString logMsg = GlobalPrivate::formatFrameworkLogOut(type,context,msg);
119 if (type == QtMsgType::QtDebugMsg)
120 fprintf(stdin,"%s\n",logMsg.toUtf8().data());
121 if (type == QtMsgType::QtInfoMsg)
122 fprintf(stderr,"%s\n",logMsg.toUtf8().data());
123 if (type == QtMsgType::QtSystemMsg)
124 fprintf(stdin,"%s\n",logMsg.toUtf8().data());
125 if (type == QtMsgType::QtCriticalMsg)
126 fprintf(stderr,"%s\n",logMsg.toUtf8().data());
127 if (type == QtMsgType::QtWarningMsg)
128 fprintf(stderr,"%s\n",logMsg.toUtf8().data());
129 if (type == QtMsgType::QtFatalMsg)
130 fprintf(stderr,"%s\n",logMsg.toUtf8().data());
131
132 // cache/deepin/qApp->applicationName()
133 LogUtils::checkAppCacheLogDir();
134
135 if (GlobalPrivate::file.fileName().isEmpty()) {
136 GlobalPrivate::file.setFileName(LogUtils::appCacheLogPath()
137 + QDir::separator()
138 + LogUtils::localDate()
139 + "_" + QCoreApplication::applicationName()
140 + ".log");
141
142 auto outMsg = GlobalPrivate::formatFrameworkLogOut(QtMsgType::QtInfoMsg,
143 QMessageLogContext{
144 __FILE__,
145 __LINE__,
146 __FUNCTION__,
147 Framework().categoryName()
148 },
149 "Current redirect log file path: "
150 + GlobalPrivate::file.fileName()
151 );
152
153 fprintf(stderr, "%s\n", outMsg.toUtf8().data());
154
155 //清除超出时间段的日志
156 GlobalPrivate::rmExpiredLogs();
157 }
158
159 if (!GlobalPrivate::file.open(QFile::Append|QFile::ReadOnly)) {
160
161 auto outMsg = GlobalPrivate::formatFrameworkLogOut(QtMsgType::QtInfoMsg,
162 QMessageLogContext{
163 __FILE__,
164 __LINE__,
165 __FUNCTION__,
166 Framework().categoryName()
167 },
168 "Failed, open redirect log file"
169 + GlobalPrivate::file.fileName()
170 + " "

Callers

nothing calls this directly

Calls 11

formatFrameworkLogOutFunction · 0.85
fileNameMethod · 0.80
setFileNameMethod · 0.80
rmExpiredLogsFunction · 0.70
dataMethod · 0.45
isEmptyMethod · 0.45
openMethod · 0.45
errorStringMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected