From ea006519632c5c78bc9af5e87d7f5c60edd17081 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sun, 19 Dec 2010 20:36:33 +0000 Subject: - Improve SPLogger to fix log issues when using SPLogger from multiple exectuables or frameworks during debug - each of which starts their own instance. --- Source/SPLogger.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Source/SPLogger.m') diff --git a/Source/SPLogger.m b/Source/SPLogger.m index 743b0fce..5736fde6 100644 --- a/Source/SPLogger.m +++ b/Source/SPLogger.m @@ -107,7 +107,10 @@ static SPLogger *logger = nil; NSString *logString = [[NSString alloc] initWithFormat:theString arguments:arguments]; va_end(arguments); - // Write the log line, forcing an immediate write to disk to ensure logging + // Write the log line, forcing an immediate write to disk to ensure logging, and + // synchronised to allow use across multiple executables or their frameworks. + [logFileHandle synchronizeFile]; + [logFileHandle seekToEndOfFile]; [logFileHandle writeData:[[NSString stringWithFormat:@"%@ %@\n", [[NSDate date] descriptionWithCalendarFormat:@"%H:%M:%S" timeZone:nil locale:[[NSUserDefaults standardUserDefaults] dictionaryRepresentation]], logString] dataUsingEncoding:NSUTF8StringEncoding]]; [logFileHandle synchronizeFile]; -- cgit v1.2.3