Bug 1902690 - Add timestamps to output using LOG_WARN r=nalexander,application-update-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D214211
This commit is contained in:
Robin Steuber 2024-06-21 16:46:25 +00:00
Родитель 4171a32712
Коммит fe840f78bc
2 изменённых файлов: 13 добавлений и 5 удалений

Просмотреть файл

@ -129,7 +129,7 @@ void UpdateLog::Flush() {
fflush(logFP);
}
void UpdateLog::Printf(const char* fmt, ...) {
void UpdateLog::PrintTimestampPrefix() {
if (!logFP) {
return;
}
@ -152,6 +152,14 @@ void UpdateLog::Printf(const char* fmt, ...) {
fprintf(logFP, "%s: ", buffer);
}
}
void UpdateLog::Printf(const char* fmt, ...) {
if (!logFP) {
return;
}
PrintTimestampPrefix();
va_list ap;
va_start(ap, fmt);
@ -159,11 +167,9 @@ void UpdateLog::Printf(const char* fmt, ...) {
va_end(ap);
fprintf(logFP, "\n");
#if defined(XP_WIN) && defined(MOZ_DEBUG)
// When the updater crashes on Windows the log file won't be flushed and this
// can make it easier to debug what is going on.
fflush(logFP);
#endif
}
void UpdateLog::WarnPrintf(const char* fmt, ...) {
@ -171,17 +177,17 @@ void UpdateLog::WarnPrintf(const char* fmt, ...) {
return;
}
PrintTimestampPrefix();
va_list ap;
va_start(ap, fmt);
fprintf(logFP, "*** Warning: ");
vfprintf(logFP, fmt, ap);
fprintf(logFP, "***\n");
va_end(ap);
#if defined(XP_WIN) && defined(MOZ_DEBUG)
// When the updater crashes on Windows the log file won't be flushed and this
// can make it easier to debug what is going on.
fflush(logFP);
#endif
}
#ifdef XP_WIN

Просмотреть файл

@ -27,6 +27,8 @@ class UpdateLog {
protected:
UpdateLog();
void PrintTimestampPrefix();
FILE* logFP;
NS_tchar mDstFilePath[MAXPATHLEN];
};