From d04a1612e5c26e2752d6c30c5aaf5289d01e90a9 Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sat, 24 Apr 2010 22:20:04 +0000 Subject: Enhance SPLogger by adding the ability to run leaks() against the application upon termination with the result being written to /tmp. To enable call setDumpLeaksOnTermination on SPLogger. Note, that SPLogger has been restructed to accommodate calling this method without writing the additional log file to the user's desktop. Could probably be enhanced a bit by someone with better C skills than me. --- Source/SPLogger.h | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'Source/SPLogger.h') diff --git a/Source/SPLogger.h b/Source/SPLogger.h index ac9b9a04..09fbfd53 100644 --- a/Source/SPLogger.h +++ b/Source/SPLogger.h @@ -27,13 +27,50 @@ @interface SPLogger : NSObject { + /** + * Dump leaks on termination flag. + */ + BOOL dumpLeaksOnTermination; + + /** + * Log file initialized successfully flag. + */ BOOL initializedSuccessfully; + + /** + * Log file handle. + */ NSFileHandle *logFileHandle; } +/** + * Returns the shared logger. + * + * @return The logger instance + */ + (SPLogger *)logger; -- (void) outputTimeString; -- (void) log:(NSString *)theString, ...; +/** + * Tells the logger to dump leaks analysis upon app termination. + */ +- (void)setDumpLeaksOnTermination; + +/** + * Dumps the result of running leaks to the file '/tmp/sp.leaks..tmp'. + * + * Note, that to enable useful output, make sure the following environment variables are set to YES: + * + * MallocStackLogging + * MallocStackLoggingNoCompact + * + * Also note that the application may take a while to terminate if it has been running for a significant + * period of time or has been handling large amounts of data. + */ +- (void)dumpLeaks; + +/** + * Logs the supplied string to the log file. + */ +- (void)log:(NSString *)theString, ...; @end -- cgit v1.2.3