From: helge Date: Fri, 12 Nov 2004 22:08:13 +0000 (+0000) Subject: cleaned up logging subproject X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61786ce866832f0620cbca47f96d87566b8eecc9;p=sope cleaned up logging subproject git-svn-id: http://svn.opengroupware.org/SOPE/trunk@367 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-core/NGExtensions/ChangeLog b/sope-core/NGExtensions/ChangeLog index 3fa31299..901c9b84 100644 --- a/sope-core/NGExtensions/ChangeLog +++ b/sope-core/NGExtensions/ChangeLog @@ -1,6 +1,10 @@ +2004-11-12 Helge Hess + + * NGLogging: code cleanup (v4.5.128) + 2004-11-12 Marcus Mueller - * GNUmakefile: added NGLogging.subproj (v4.3.127) + * GNUmakefile: added NGLogging.subproj (v4.5.127) 2004-10-21 Helge Hess diff --git a/sope-core/NGExtensions/NGExtensions/NGLogAppender.h b/sope-core/NGExtensions/NGExtensions/NGLogAppender.h index 975a50c4..3de602ac 100644 --- a/sope-core/NGExtensions/NGExtensions/NGLogAppender.h +++ b/sope-core/NGExtensions/NGExtensions/NGLogAppender.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2004 SKYRIX Software AG + Copyright (C) 2004 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -23,11 +23,11 @@ #define __NGExtensions_NGLogAppender_H_ /* - Abstract superclass for all appenders. + Abstract superclass for all log appenders. */ -#import -#include +#import +#include /* for LogLevel */ @class NGLogEvent; diff --git a/sope-core/NGExtensions/NGExtensions/NGLogConsoleAppender.h b/sope-core/NGExtensions/NGExtensions/NGLogConsoleAppender.h index 90fc9b04..ec8c8b74 100644 --- a/sope-core/NGExtensions/NGExtensions/NGLogConsoleAppender.h +++ b/sope-core/NGExtensions/NGExtensions/NGLogConsoleAppender.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2004 SKYRIX Software AG + Copyright (C) 2004 SKYRIX Software AG This file is part of OpenGroupware.org. diff --git a/sope-core/NGExtensions/NGExtensions/NGLogEvent.h b/sope-core/NGExtensions/NGExtensions/NGLogEvent.h index 8d541bc8..b507c96f 100644 --- a/sope-core/NGExtensions/NGExtensions/NGLogEvent.h +++ b/sope-core/NGExtensions/NGExtensions/NGLogEvent.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2004 SKYRIX Software AG + Copyright (C) 2004 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -22,19 +22,24 @@ #ifndef __NGExtensions_NGLogEvent_H_ #define __NGExtensions_NGLogEvent_H_ -#import -#include +#import +#import +#include /* for NGLogLevel */ + +@class NSString; @interface NGLogEvent : NSObject { - NSString *msg; - NGLogLevel level; + NSString *msg; + NGLogLevel level; NSTimeInterval date; } - (id)initWithLevel:(NGLogLevel)_level message:(NSString *)_msg; +/* accessors */ + - (NGLogLevel)level; - (NSString *)message; - (NSDate *)date; diff --git a/sope-core/NGExtensions/NGExtensions/NGLogSyslogAppender.h b/sope-core/NGExtensions/NGExtensions/NGLogSyslogAppender.h index 4e3b99f7..2539e7b6 100644 --- a/sope-core/NGExtensions/NGExtensions/NGLogSyslogAppender.h +++ b/sope-core/NGExtensions/NGExtensions/NGLogSyslogAppender.h @@ -24,6 +24,14 @@ #include +/* + NGLogSyslogAppender + + An appender which writes to the systems syslog facility. +*/ + +@class NSString; + @interface NGLogSyslogAppender : NGLogAppender { } diff --git a/sope-core/NGExtensions/NGExtensions/NGLogger.h b/sope-core/NGExtensions/NGExtensions/NGLogger.h index 1e9ddfcc..d5dbda1a 100644 --- a/sope-core/NGExtensions/NGExtensions/NGLogger.h +++ b/sope-core/NGExtensions/NGExtensions/NGLogger.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2004 SKYRIX Software AG + Copyright (C) 2004 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -23,27 +23,34 @@ #define __NGExtensions_NGLogger_H_ /* - The logger, modeled closely after log4j. - */ + NGLogger + + A logger class, modeled closely after Log4J. + + TODO: explain more. +*/ -#import +#import #include - @interface NGLogger : NSObject { NGLogLevel logLevel; - id _appender; // going away as soon as we have a config + id _appender; // going away as soon as we have a config } - (id)initWithLogLevel:(NGLogLevel)_level; -- (void)logLevel:(NGLogLevel)_level message:(NSString *)_msg; -- (void)logLevel:(NGLogLevel)_level withFormat:(NSString *)_fmt, ...; +/* accessors */ - (void)setLogLevel:(NGLogLevel)_level; - (NGLogLevel)logLevel; +/* logging */ + +- (void)logLevel:(NGLogLevel)_level message:(NSString *)_msg; +- (void)logLevel:(NGLogLevel)_level withFormat:(NSString *)_fmt, ...; + @end #endif /* __NGExtensions_NGLogger_H_ */ diff --git a/sope-core/NGExtensions/NGExtensions/NGLoggerManager.h b/sope-core/NGExtensions/NGExtensions/NGLoggerManager.h index 26214f5c..b83c1398 100644 --- a/sope-core/NGExtensions/NGExtensions/NGLoggerManager.h +++ b/sope-core/NGExtensions/NGExtensions/NGLoggerManager.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2000-2004 SKYRIX Software AG + Copyright (C) 2004 SKYRIX Software AG This file is part of OpenGroupware.org. @@ -22,8 +22,9 @@ #ifndef __NGExtensions_NGLoggerManager_H_ #define __NGExtensions_NGLoggerManager_H_ -#import +#import +@class NSString, NSMutableDictionary; @class NGLogger; @interface NGLoggerManager : NSObject @@ -31,7 +32,9 @@ NSMutableDictionary *loggerMap; } -+ (id)defaultManager; ++ (id)defaultLoggerManager; + +/* operations */ - (NGLogger *)loggerForDefaultKey:(NSString *)_defaultKey; diff --git a/sope-core/NGExtensions/NGExtensions/NSObject+ExtendedLogging.h b/sope-core/NGExtensions/NGExtensions/NSObject+ExtendedLogging.h index 15524414..548f0778 100644 --- a/sope-core/NGExtensions/NGExtensions/NSObject+ExtendedLogging.h +++ b/sope-core/NGExtensions/NGExtensions/NSObject+ExtendedLogging.h @@ -22,7 +22,7 @@ #ifndef __NSObject_ExtendedLogging_H_ #define __NSObject_ExtendedLogging_H_ -#import +#import typedef enum { NGLogLevelOff = 0, @@ -34,22 +34,28 @@ typedef enum { NGLogLevelAll = 6 } NGLogLevel; -@interface NSObject (NGExtendedLogging) +@interface NSObject(NGExtendedLogging) - (id)logger; +/* convenience methods */ + - (void)logDebugWithFormat:(NSString *)_fmt, ...; - (void)logInfoWithFormat:(NSString *)_fmt, ...; - (void)logWarnWithFormat:(NSString *)_fmt, ...; - (void)logErrorWithFormat:(NSString *)_fmt, ...; - (void)logFatalWithFormat:(NSString *)_fmt, ...; +/* conditions (try to avoid these, slow!) */ + - (BOOL)isLogDebugEnabled; - (BOOL)isLogInfoEnabled; - (BOOL)isLogWarnEnabled; - (BOOL)isLogErrorEnabled; - (BOOL)isLogFatalEnabled; +/* generic methods */ + - (void)logLevel:(NGLogLevel)_level message:(NSString *)_msg; - (void)logLevel:(NGLogLevel)_level withFormat:(NSString *)_fmt, ...; diff --git a/sope-core/NGExtensions/NGLogging.subproj/ChangeLog b/sope-core/NGExtensions/NGLogging.subproj/ChangeLog index 21714836..3996480a 100644 --- a/sope-core/NGExtensions/NGLogging.subproj/ChangeLog +++ b/sope-core/NGExtensions/NGLogging.subproj/ChangeLog @@ -1,3 +1,9 @@ +2004-11-12 Helge Hess + + * deprecated -defaultManager in favor of -defaultLoggerManager + + * code cleanups for SOPE styleguides + 2004-11-12 Marcus Mueller * NSObject+ExtendedLogging.[hm]: -(id)logger queries NGLoggerManager diff --git a/sope-core/NGExtensions/NGLogging.subproj/GNUmakefile b/sope-core/NGExtensions/NGLogging.subproj/GNUmakefile index 9f3bcf11..90d83e25 100644 --- a/sope-core/NGExtensions/NGLogging.subproj/GNUmakefile +++ b/sope-core/NGExtensions/NGLogging.subproj/GNUmakefile @@ -5,15 +5,18 @@ include ../../common.make SUBPROJECT_NAME = NGLogging -NGLogging_OBJC_FILES = \ +NGLogging_OBJC_FILES += \ NGLogger.m \ NGLoggerManager.m \ NGLogEvent.m \ NGLogAppender.m \ NGLogConsoleAppender.m \ - NGLogSyslogAppender.m \ NSObject+ExtendedLogging.m \ +# TODO: disable on Windows +NGLogging_OBJC_FILES += \ + NGLogSyslogAppender.m + ADDITIONAL_INCLUDE_DIRS += -I. -I../NGExtensions/ -I.. -I../.. -include GNUmakefile.preamble diff --git a/sope-core/NGExtensions/NGLogging.subproj/NGLogAppender.m b/sope-core/NGExtensions/NGLogging.subproj/NGLogAppender.m index 86211367..38e5adb3 100644 --- a/sope-core/NGExtensions/NGLogging.subproj/NGLogAppender.m +++ b/sope-core/NGExtensions/NGLogging.subproj/NGLogAppender.m @@ -1,23 +1,23 @@ /* - Copyright (C) 2000-2004 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - */ + Copyright (C) 2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ #include "NGLogAppender.h" #include "NSObject+ExtendedLogging.h" @@ -61,4 +61,4 @@ return name; } -@end +@end /* NGLogAppender */ diff --git a/sope-core/NGExtensions/NGLogging.subproj/NGLogEvent.m b/sope-core/NGExtensions/NGLogging.subproj/NGLogEvent.m index eb68b136..fc99bef1 100644 --- a/sope-core/NGExtensions/NGLogging.subproj/NGLogEvent.m +++ b/sope-core/NGExtensions/NGLogging.subproj/NGLogEvent.m @@ -1,34 +1,40 @@ /* - Copyright (C) 2000-2004 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - */ + Copyright (C) 2000-2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ #include "NGLogEvent.h" #include "common.h" @implementation NGLogEvent +static Class DateClass = Nil; + ++ (void)initialize { + DateClass = [NSDate class]; +} + - (id)initWithLevel:(NGLogLevel)_level message:(NSString *)_msg { if((self = [super init])) { - self->date = [NSDate timeIntervalSinceReferenceDate]; + self->date = [DateClass timeIntervalSinceReferenceDate]; self->level = _level; - ASSIGN(self->msg, _msg); + self->msg = [_msg copy]; } return self; } @@ -38,6 +44,8 @@ [super dealloc]; } +/* accessors */ + - (NGLogLevel)level { return self->level; } @@ -47,7 +55,7 @@ } - (NSDate *)date { - return [NSDate dateWithTimeIntervalSinceReferenceDate:self->date]; + return [DateClass dateWithTimeIntervalSinceReferenceDate:self->date]; } -@end +@end /* NGLogEvent */ diff --git a/sope-core/NGExtensions/NGLogging.subproj/NGLogSyslogAppender.m b/sope-core/NGExtensions/NGLogging.subproj/NGLogSyslogAppender.m index dc65fdd3..430dadab 100644 --- a/sope-core/NGExtensions/NGLogging.subproj/NGLogSyslogAppender.m +++ b/sope-core/NGExtensions/NGLogging.subproj/NGLogSyslogAppender.m @@ -1,23 +1,23 @@ /* - Copyright (C) 2000-2004 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - */ + Copyright (C) 2000-2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ #include "NGLogSyslogAppender.h" #include "NGLogEvent.h" @@ -36,7 +36,7 @@ static NSString *defaultSyslogIdentifier = nil; NSUserDefaults *ud; static BOOL isInitialized = NO; - if(isInitialized) + if (isInitialized) return; ud = [NSUserDefaults standardUserDefaults]; @@ -48,7 +48,7 @@ static NSString *defaultSyslogIdentifier = nil; + (id)sharedAppender { static id sharedAppender = nil; - if(sharedAppender == nil) { + if (sharedAppender == nil) { sharedAppender = [[self alloc] init]; } return sharedAppender; @@ -59,8 +59,9 @@ static NSString *defaultSyslogIdentifier = nil; } - (id)initWithIdentifier:(NSString *)_ident { - if((self = [super init])) { -#warning ** default flags? + if ((self = [super init])) { + // TODO: default flags? + // TODO: error code processing? openlog([_ident cString], LOG_PID | LOG_NDELAY, LOG_USER); } return self; @@ -71,6 +72,8 @@ static NSString *defaultSyslogIdentifier = nil; [super dealloc]; } +/* operations */ + - (void)appendLogEvent:(NGLogEvent *)_event { NSString *formattedMsg; int level; @@ -106,4 +109,4 @@ static NSString *defaultSyslogIdentifier = nil; return level; } -@end +@end /* NGLogSyslogAppender */ diff --git a/sope-core/NGExtensions/NGLogging.subproj/NGLogger.m b/sope-core/NGExtensions/NGLogging.subproj/NGLogger.m index 5cfcd907..0799ac9a 100644 --- a/sope-core/NGExtensions/NGLogging.subproj/NGLogger.m +++ b/sope-core/NGExtensions/NGLogging.subproj/NGLogger.m @@ -1,23 +1,23 @@ /* - Copyright (C) 2000-2004 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - */ + Copyright (C) 2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ #include "NGLogger.h" #include "common.h" @@ -26,22 +26,27 @@ @implementation NGLogger +static Class StrClass = Nil; + ++ (void)initialize { + StrClass = [NSString class]; +} + - (id)init { - self = [self initWithLogLevel:NGLogLevelAll]; - return self; + return [self initWithLogLevel:NGLogLevelAll]; } - (id)initWithLogLevel:(NGLogLevel)_level { - if((self = [super init])) { + if ((self = [super init])) { NSUserDefaults *ud; NSString *appenderClassName; [self setLogLevel:_level]; -#warning ** remove this as soon as we have a config + // TODO: remove this as soon as we have a config ud = [NSUserDefaults standardUserDefaults]; appenderClassName = [ud stringForKey:@"NGLogDefaultAppenderClass"]; - if(appenderClassName == nil) + if (appenderClassName == nil) appenderClassName = @"NGLogConsoleAppender"; self->_appender = [[NSClassFromString(appenderClassName) alloc] init]; } @@ -53,6 +58,7 @@ [super dealloc]; } +/* accessors */ - (void)setLogLevel:(NGLogLevel)_level { self->logLevel = _level; @@ -62,6 +68,8 @@ return self->logLevel; } +/* logging */ + - (void)logLevel:(NGLogLevel)_level withFormat:(NSString *)_fmt, ... { NSString *msg; va_list va; @@ -70,7 +78,7 @@ return; va_start(va, _fmt); - msg = [[NSString alloc] initWithFormat:_fmt arguments:va]; + msg = [[StrClass alloc] initWithFormat:_fmt arguments:va]; va_end(va); [self logLevel:_level message:msg]; [msg release]; @@ -80,13 +88,15 @@ NGLogEvent *event; event = [[NGLogEvent alloc] initWithLevel:_level message:_msg]; - + // iterate appenders // TODO: as soon as we have more appenders, we need to iterate on them [self->_appender appendLogEvent:event]; [event release]; } +/* log conditions */ + - (BOOL)isLogDebugEnabled { return self->logLevel >= NGLogLevelDebug; } @@ -107,4 +117,4 @@ return self->logLevel >= NGLogLevelFatal; } -@end +@end /* NGLogger */ diff --git a/sope-core/NGExtensions/NGLogging.subproj/NGLoggerManager.m b/sope-core/NGExtensions/NGLogging.subproj/NGLoggerManager.m index d56129f2..d598e8b0 100644 --- a/sope-core/NGExtensions/NGLogging.subproj/NGLoggerManager.m +++ b/sope-core/NGExtensions/NGLogging.subproj/NGLoggerManager.m @@ -22,6 +22,7 @@ #include "NGLoggerManager.h" #include "NSObject+ExtendedLogging.h" #include "NGLogger.h" +#include "common.h" @interface NGLoggerManager (PrivateAPI) - (NGLogLevel)_logLevelForString:(NSString *)_defaultValue; @@ -35,21 +36,25 @@ static NSNull *sharedNull; + (void)initialize { static BOOL didInit = NO; - if(didInit) + if (didInit) return; didInit = YES; sharedInstance = [[self alloc] init]; - sharedNull = [NSNull null]; + sharedNull = [[NSNull null] retain]; } -+ (id)defaultManager { ++ (id)defaultLoggerManager { return sharedInstance; } ++ (id)defaultManager { + NSLog(@"WARNING(%s): called deprecated method.", __PRETTY_FUNCTION__); + return [self defaultLoggerManager]; +} - (id)init { self = [super init]; - if(self) { + if (self) { self->loggerMap = [[NSMutableDictionary alloc] initWithCapacity:50]; } return self; @@ -60,11 +65,13 @@ static NSNull *sharedNull; [super dealloc]; } +/* operations */ + - (NGLogger *)loggerForDefaultKey:(NSString *)_defaultKey { id logger; logger = [self->loggerMap objectForKey:_defaultKey]; - if(!logger) { + if (!logger) { NSUserDefaults *ud; NSString *levelId; NGLogLevel level; @@ -72,7 +79,7 @@ static NSNull *sharedNull; ud = [NSUserDefaults standardUserDefaults]; levelId = [[ud stringForKey:_defaultKey] uppercaseString]; level = [self _logLevelForString:levelId]; - if(level == NGLogLevelOff) { + if (level == NGLogLevelOff) { [self->loggerMap setObject:sharedNull forKey:_defaultKey]; logger = sharedNull; } @@ -88,20 +95,23 @@ static NSNull *sharedNull; /* Private */ - (NGLogLevel)_logLevelForString:(NSString *)_defaultValue { - if(!_defaultValue || [_defaultValue isEqualToString:@"NO"]) + if ([_defaultValue length] == 0 || [_defaultValue isEqualToString:@"NO"]) return NGLogLevelOff; - else if([_defaultValue isEqualToString:@"YES"] || + + if ([_defaultValue isEqualToString:@"YES"] || [_defaultValue isEqualToString:@"DEBUG"]) return NGLogLevelDebug; - else if([_defaultValue isEqualToString:@"INFO"]) + + if ([_defaultValue isEqualToString:@"INFO"]) return NGLogLevelInfo; - else if([_defaultValue isEqualToString:@"WARN"]) + if ([_defaultValue isEqualToString:@"WARN"]) return NGLogLevelWarn; - else if([_defaultValue isEqualToString:@"ERROR"]) + if ([_defaultValue isEqualToString:@"ERROR"]) return NGLogLevelError; - else if([_defaultValue isEqualToString:@"FATAL"]) + if ([_defaultValue isEqualToString:@"FATAL"]) return NGLogLevelFatal; + return NGLogLevelAll; } -@end +@end /* NGLoggerManager */ diff --git a/sope-core/NGExtensions/NGLogging.subproj/NSObject+ExtendedLogging.m b/sope-core/NGExtensions/NGLogging.subproj/NSObject+ExtendedLogging.m index 99ed6790..0e28bf2d 100644 --- a/sope-core/NGExtensions/NGLogging.subproj/NSObject+ExtendedLogging.m +++ b/sope-core/NGExtensions/NGLogging.subproj/NSObject+ExtendedLogging.m @@ -1,43 +1,48 @@ /* - Copyright (C) 2000-2004 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. - */ + Copyright (C) 2004 SKYRIX Software AG + + This file is part of OpenGroupware.org. + + OGo is free software; you can redistribute it and/or modify it under + the terms of the GNU Lesser General Public License as published by the + Free Software Foundation; either version 2, or (at your option) any + later version. + + OGo is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with OGo; see the file COPYING. If not, write to the + Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. +*/ #include "NSObject+ExtendedLogging.h" #include "NGLogger.h" #include "NGLoggerManager.h" +#include "common.h" -@implementation NSObject (NGExtendedLogging) +@implementation NSObject(NGExtendedLogging) - (id)logger { static id sharedLogger = nil; static BOOL shouldLog = YES; - if(sharedLogger == nil && shouldLog) { + + if (sharedLogger == nil && shouldLog) { NGLoggerManager *lm; - lm = [NGLoggerManager defaultManager]; + + lm = [NGLoggerManager defaultLoggerManager]; sharedLogger = [lm loggerForDefaultKey:@"NGDefaultLogLevel"]; - if(!sharedLogger) + if (!sharedLogger) shouldLog = NO; } return sharedLogger; } +/* log methods */ + - (void)logDebugWithFormat:(NSString *)_fmt, ... { NSString *msg; va_list va; @@ -108,6 +113,8 @@ [msg release]; } +/* log conditions (do not use, slow ...) */ + - (BOOL)isLogDebugEnabled { return [[self logger] isLogDebugEnabled]; } @@ -128,4 +135,4 @@ return [[self logger] isLogFatalEnabled]; } -@end +@end /* NSObject(NGExtendedLogging) */ diff --git a/sope-core/NGExtensions/Version b/sope-core/NGExtensions/Version index 5ddb9af7..195a3590 100644 --- a/sope-core/NGExtensions/Version +++ b/sope-core/NGExtensions/Version @@ -1,6 +1,6 @@ # version -SUBMINOR_VERSION:=127 +SUBMINOR_VERSION:=128 # v4.3.115 requires libFoundation v1.0.59 # v4.2.72 requires libEOControl v4.2.39