@implementation SOGoAppointmentFolder
-static BOOL debugOn = NO;
+static NGLogger *logger = nil;
static NSTimeZone *MET = nil;
+ (void)initialize {
- static BOOL didInit = NO;
+ NGLoggerManager *lm;
+ static BOOL didInit = NO;
if (didInit) return;
didInit = YES;
+ lm = [NGLoggerManager defaultLoggerManager];
+ logger = [lm loggerForDefaultKey:@"SOGoAppointmentFolderDebugEnabled"];
+
MET = [[NSTimeZone timeZoneWithAbbreviation:@"MET"] retain];
}
[super dealloc];
}
+
+/* logging */
+
+- (NGLogger *)debugLogger {
+ return logger;
+}
+
/* selection */
- (NSArray *)calendarUIDs {
/* prepare mandatory fields */
- fields = [NSMutableArray arrayWithArray:_fields];
+ fields = [NSMutableArray arrayWithArray:_fields];
[fields addObject:@"uid"];
[fields addObject:@"startdate"];
[fields addObject:@"enddate"];
- if (debugOn)
+ if (logger)
[self debugWithFormat:@"should fetch (%@=>%@) ...", _startDate, _endDate];
sql = [NSString stringWithFormat:@"(startdate < %d) AND (enddate > %d)"
records = [_folder fetchFields:fields matchingQualifier:qualifier];
if (records != nil) {
records = [self fixupRecords:records fetchRange:r];
- if (debugOn)
- [self logWithFormat:@"fetched %i records: %@", [records count], records];
+ if (logger)
+ [self debugWithFormat:@"fetched %i records: %@", [records count], records];
ma = [NSMutableArray arrayWithArray:records];
}
records = [_folder fetchFields:fields matchingQualifier:qualifier];
if (records != nil) {
- if (debugOn)
- [self logWithFormat:@"fetched %i cyclic records: %@",
+ if (logger)
+ [self debugWithFormat:@"fetched %i cyclic records: %@",
[records count], records];
records = [self fixupCyclicRecords:records fetchRange:r];
if (!ma) ma = [NSMutableArray arrayWithCapacity:[records count]];
[self errorWithFormat:@"(%s): fetch failed!", __PRETTY_FUNCTION__];
return nil;
}
-
+ if (logger)
+ [self debugWithFormat:@"returning %i records", [ma count]];
return ma;
}