Skip to content

Commit 3c4d40b

Browse files
DEBUG: file logging
1 parent 5eff626 commit 3c4d40b

File tree

1 file changed

+37
-13
lines changed

1 file changed

+37
-13
lines changed

Monal/Classes/HelperTools.m

+37-13
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,11 @@ void logException(NSException* exception)
275275
NSString* prefix = @"CRASH";
276276
#endif
277277
//log error and flush all logs
278+
DDLogWarn(@"Crash pending!!!");
278279
[DDLog flushLog];
279280
DDLogError(@"*****************\n%@(%@): %@\nUserInfo: %@\nStack Trace: %@", prefix, [exception name], [exception reason], [exception userInfo], [exception callStackSymbols]);
280281
[DDLog flushLog];
282+
DDLogWarn(@"Crash logged!!!");
281283
[HelperTools flushLogsWithTimeout:0.250];
282284
}
283285

@@ -286,11 +288,11 @@ void uncaughtExceptionHandler(NSException* exception)
286288
logException(exception);
287289

288290
//don't report that crash through KSCrash if the debugger is active
289-
if(isDebugerActive())
290-
{
291-
DDLogError(@"Not reporting crash through KSCrash: debugger is active!");
292-
return;
293-
}
291+
// if(isDebugerActive())
292+
// {
293+
// DDLogError(@"Not reporting crash through KSCrash: debugger is active!");
294+
// return;
295+
// }
294296

295297
//make sure this crash will be recorded by kscrash using the NSException rather than the c++ exception thrown by the objc runtime
296298
//this will make sure that the stacktrace matches the objc exception rather than being a top level c++ stacktrace
@@ -599,10 +601,10 @@ +(void) initSystem
599601
{
600602
[self configureLogging];
601603
//don't install KSCrash if the debugger is active
602-
if(!isDebugerActive())
604+
//if(!isDebugerActive())
603605
[self installCrashHandler];
604-
else
605-
DDLogWarn(@"Not installing crash handler: debugger is active!");
606+
// else
607+
// DDLogWarn(@"Not installing crash handler: debugger is active!");
606608
[self installExceptionHandler];
607609
}
608610
else
@@ -2220,6 +2222,8 @@ +(void) configureXcodeLogging
22202222

22212223
+(void) configureLogging
22222224
{
2225+
NSError* error;
2226+
22232227
//network logger (start as early as possible)
22242228
MLUDPLogger* udpLogger = [MLUDPLogger new];
22252229
[DDLog addLogger:udpLogger];
@@ -2233,10 +2237,17 @@ +(void) configureLogging
22332237
printf("stdout redirection complete...");
22342238

22352239
//redirect apple system logs, too
2236-
#pragma clang diagnostic push
2237-
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
2238-
[DDASLLogCapture start];
2239-
#pragma clang diagnostic pop
2240+
/*
2241+
OSLogStore* osLogStore = [OSLogStore storeWithScope:OSLogStoreCurrentProcessIdentifier error:&error];
2242+
if(error)
2243+
DDLogError(@"Failed to open os log store: %@", error);
2244+
else
2245+
{
2246+
dispatch_async(, ^{
2247+
[osLogStore entriesEnumeratorAndReturnError:&error];
2248+
});
2249+
}
2250+
*/
22402251

22412252
NSString* containerUrl = [[HelperTools getContainerURLForPathComponents:@[]] path];
22422253
DDLogInfo(@"Logfile dir: %@", containerUrl);
@@ -2253,7 +2264,6 @@ +(void) configureLogging
22532264

22542265
DDLogDebug(@"Sorted logfiles: %@", [logFileManager sortedLogFileInfos]);
22552266
DDLogDebug(@"Current logfile: %@", self.fileLogger.currentLogFileInfo.filePath);
2256-
NSError* error;
22572267
NSDictionary* attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:self.fileLogger.currentLogFileInfo.filePath error:&error];
22582268
if(error)
22592269
DDLogError(@"File attributes error: %@", error);
@@ -2281,6 +2291,20 @@ +(void) configureLogging
22812291
NSArray* directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:containerUrl error:nil];
22822292
for(NSString* file in directoryContents)
22832293
DDLogVerbose(@"File %@/%@", containerUrl, file);
2294+
2295+
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
2296+
NSString* documentsUrl = [paths objectAtIndex:0];
2297+
documentsUrl = [documentsUrl stringByAppendingPathComponent:@".."];
2298+
documentsUrl = [documentsUrl stringByAppendingPathComponent:@"Library"];
2299+
directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsUrl error:nil];
2300+
for(NSString* file in directoryContents)
2301+
DDLogVerbose(@"App File %@/%@", documentsUrl, file);
2302+
documentsUrl = [paths objectAtIndex:0];
2303+
documentsUrl = [documentsUrl stringByAppendingPathComponent:@".."];
2304+
documentsUrl = [documentsUrl stringByAppendingPathComponent:@"SystemData"];
2305+
directoryContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:documentsUrl error:nil];
2306+
for(NSString* file in directoryContents)
2307+
DDLogVerbose(@"App File %@/%@", documentsUrl, file);
22842308
}
22852309

22862310
+(int) pendingCrashreportCount

0 commit comments

Comments
 (0)