mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-27 05:04:27 +00:00
Don't call SUClearLog() unless logging something
Don't delete the log file and log app name to it when only checking for updates - this is something done frequently, on many apps' startup. Instead, clear the log before writing the first entry to it, so that it stays untouched if there's nothing to add to it. Log the application name before the first "real" log entry, instead of doing it unconditionally every time checkForUpdatesWithDriver: is called.
This commit is contained in:
1 parent
313b146b8e
commit
b9f987382c
2 files changed
+7
-3
No files matched your search
Vendored
+7
@@ -37,6 +37,7 @@ void SUClearLog(void)
|
||||
FILE *logfile = fopen([[SULogFilePath stringByExpandingTildeInPath] fileSystemRepresentation], "w");
|
||||
if (logfile) {
|
||||
fclose(logfile);
|
||||
SULog(@"===== %@ =====", [[NSFileManager defaultManager] displayNameAtPath:[[NSBundle mainBundle] bundlePath]]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +54,12 @@ void SUClearLog(void)
|
||||
|
||||
void SULog(NSString *format, ...)
|
||||
{
|
||||
static BOOL loggedYet = NO;
|
||||
if (!loggedYet) {
|
||||
loggedYet = YES;
|
||||
SUClearLog();
|
||||
}
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
NSString *theStr = [[NSString alloc] initWithFormat:format arguments:ap];
|
||||
|
||||
Vendored
-3
@@ -332,9 +332,6 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
|
||||
if ([self updateInProgress]) { return; }
|
||||
if (self.checkTimer) { [self.checkTimer invalidate]; self.checkTimer = nil; } // Timer is non-repeating, may have invalidated itself, so we had to retain it.
|
||||
|
||||
SUClearLog();
|
||||
SULog(@"===== %@ =====", [[NSFileManager defaultManager] displayNameAtPath:[[NSBundle mainBundle] bundlePath]]);
|
||||
|
||||
[self willChangeValueForKey:@"lastUpdateCheckDate"];
|
||||
[self.host setObject:[NSDate date] forUserDefaultsKey:SULastCheckTimeKey];
|
||||
[self didChangeValueForKey:@"lastUpdateCheckDate"];
|
||||
|
||||
Reference in new issue
Block a user