aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPLogger.m
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-04-25 16:47:34 +0000
committerstuconnolly <stuart02@gmail.com>2010-04-25 16:47:34 +0000
commited48d6800ff18def939d2ec8ce804cf54839067a (patch)
tree0a384b39134666cc954897a57133cc1227d3a5e1 /Source/SPLogger.m
parentfe6d4051cd47ee24c33775eec8624ebd7bb42160 (diff)
downloadsequelpro-ed48d6800ff18def939d2ec8ce804cf54839067a.tar.gz
sequelpro-ed48d6800ff18def939d2ec8ce804cf54839067a.tar.bz2
sequelpro-ed48d6800ff18def939d2ec8ce804cf54839067a.zip
Add the option to set whether or not old leaks logs are deleted.
Diffstat (limited to 'Source/SPLogger.m')
-rw-r--r--Source/SPLogger.m69
1 files changed, 36 insertions, 33 deletions
diff --git a/Source/SPLogger.m b/Source/SPLogger.m
index 8870ed49..83c5b49c 100644
--- a/Source/SPLogger.m
+++ b/Source/SPLogger.m
@@ -53,6 +53,9 @@ static SPLogger *logger = nil;
@implementation SPLogger
+@synthesize dumpLeaksOnTermination;
+@synthesize removeOldLeakDumpsOnTermination;
+
/*
* Returns the shared logger object.
*/
@@ -90,8 +93,10 @@ static SPLogger *logger = nil;
- (id)init
{
if ((self = [super init])) {
- dumpLeaksOnTermination = NO;
initializedSuccessfully = YES;
+
+ [self setDumpLeaksOnTermination:NO];
+ [self setRemoveOldLeakDumpsOnTermination:YES];
}
return self;
@@ -119,19 +124,9 @@ static SPLogger *logger = nil;
[logString release];
}
-- (void)setDumpLeaksOnTermination
-{
- dumpLeaksOnTermination = YES;
-}
-
- (void)dumpLeaks
{
- if (dumpLeaksOnTermination) {
-
- // Remove old leaks logs
- int cnt, cnt2, i;
- int isSPLeaksLog();
- struct direct **files;
+ if ([self dumpLeaksOnTermination]) {
char *lgn;
struct passwd *pw;
@@ -145,34 +140,42 @@ static SPLogger *logger = nil;
hdir = TRUE;
}
- cnt = scandir("/tmp", &files, isSPLeaksLog, NULL);
-
- char fpath[32], fpath2[32], fpath3[64];
-
- for (i = 0; i < cnt; i++)
- {
- snprintf(fpath, sizeof(fpath), "/tmp/%s", files[i]->d_name);
+ // If required remove old logs
+ if ([self removeOldLeakDumpsOnTermination]) {
- if (remove(fpath) != 0) {
- printf("Unable to remove Sequel Pro leaks log '%s'\n", files[i]->d_name);
- }
- }
-
- free(&files);
-
- if (hdir) {
- snprintf(fpath2, sizeof(fpath2), "%s/Desktop", pw->pw_dir);
-
- cnt2 = scandir(fpath2, &files, isSPLeaksLog, NULL);
+ int cnt, cnt2, i;
+ int isSPLeaksLog();
+ struct direct **files;
+
+ cnt = scandir("/tmp", &files, isSPLeaksLog, NULL);
- for (i = 0; i < cnt2; i++)
+ char fpath[32], fpath2[32], fpath3[64];
+
+ for (i = 0; i < cnt; i++)
{
- snprintf(fpath3, sizeof(fpath3), "%s/%s", fpath2, files[i]->d_name);
+ snprintf(fpath, sizeof(fpath), "/tmp/%s", files[i]->d_name);
- if (remove(fpath3) != 0) {
+ if (remove(fpath) != 0) {
printf("Unable to remove Sequel Pro leaks log '%s'\n", files[i]->d_name);
}
}
+
+ free(&files);
+
+ if (hdir) {
+ snprintf(fpath2, sizeof(fpath2), "%s/Desktop", pw->pw_dir);
+
+ cnt2 = scandir(fpath2, &files, isSPLeaksLog, NULL);
+
+ for (i = 0; i < cnt2; i++)
+ {
+ snprintf(fpath3, sizeof(fpath3), "%s/%s", fpath2, files[i]->d_name);
+
+ if (remove(fpath3) != 0) {
+ printf("Unable to remove Sequel Pro leaks log '%s'\n", files[i]->d_name);
+ }
+ }
+ }
}
size_t len;