+2004-11-17 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * NGLogging: updated (v4.5.131)
+
2004-11-17 Matthew Joyce <mjoyce@aboveit.nl>
* NGBundleManager.m: check whether bundle is nil prior running a type
typedef enum {
NGLogLevelOff = 0,
- NGLogLevelDebug = 1,
- NGLogLevelInfo = 2,
+ NGLogLevelFatal = 1,
+ NGLogLevelError = 2,
NGLogLevelWarn = 3,
- NGLogLevelError = 4,
- NGLogLevelFatal = 5,
+ NGLogLevelInfo = 4,
+ NGLogLevelDebug = 5,
NGLogLevelAll = 6
} NGLogLevel;
+2004-11-17 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * NSObject+NGExtendedLogging.h: fixed some serious misordering in
+ log levels (thanks to Helge Hess for reporting this! ;-)
+
+ * NSObject+NGExtendedLogging.m: some optimizations to default logging
+ facilities (check wheter loglevel is enabled before allocating
+ strings which is expensive).
+
+ * NGLogger.m: changed some code to address changes in NGLogLevel,
+ shortcut logging immediately if minimum log level is not met.
+
2004-11-12 Helge Hess <helge.hess@opengroupware.org>
* deprecated -defaultManager in favor of -defaultLoggerManager
@implementation NGLogger
-static Class StrClass = Nil;
+static Class NSStringClass = Nil;
+ (void)initialize {
- StrClass = [NSString class];
+ static BOOL didInit = NO;
+ if(didInit)
+ return;
+ didInit = YES;
+ NSStringClass = [NSString class];
}
- (id)init {
- (void)setLogLevel:(NGLogLevel)_level {
self->logLevel = _level;
}
-
- (NGLogLevel)logLevel {
return self->logLevel;
}
/* logging */
+- (void)logLevel:(NGLogLevel)_level message:(NSString *)_msg {
+ NGLogEvent *event;
+
+ if(self->logLevel < _level)
+ return;
+
+ 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];
+}
+
- (void)logLevel:(NGLogLevel)_level withFormat:(NSString *)_fmt, ... {
NSString *msg;
va_list va;
- if(self->logLevel > _level)
+ if(self->logLevel < _level)
return;
va_start(va, _fmt);
- msg = [[StrClass alloc] initWithFormat:_fmt arguments:va];
+ msg = [[NSStringClass alloc] initWithFormat:_fmt arguments:va];
va_end(va);
[self logLevel:_level message:msg];
[msg release];
}
-- (void)logLevel:(NGLogLevel)_level message:(NSString *)_msg {
- 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;
}
-
- (BOOL)isLogInfoEnabled {
return self->logLevel >= NGLogLevelInfo;
}
-
- (BOOL)isLogWarnEnabled {
return self->logLevel >= NGLogLevelWarn;
}
-
- (BOOL)isLogErrorEnabled {
return self->logLevel >= NGLogLevelError;
}
-
- (BOOL)isLogFatalEnabled {
return self->logLevel >= NGLogLevelFatal;
}
/* log methods */
- (void)logDebugWithFormat:(NSString *)_fmt, ... {
+ NGLogger *logger;
NSString *msg;
va_list va;
+ logger = [self logger];
+ if(![logger isLogDebugEnabled])
+ return;
+
va_start(va, _fmt);
msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
va_end(va);
- [self logLevel:NGLogLevelDebug message:msg];
+ [logger logLevel:NGLogLevelDebug message:msg];
[msg release];
}
- (void)logInfoWithFormat:(NSString *)_fmt, ... {
+ NGLogger *logger;
NSString *msg;
va_list va;
+ logger = [self logger];
+ if(![logger isLogInfoEnabled])
+ return;
+
va_start(va, _fmt);
msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
va_end(va);
- [self logLevel:NGLogLevelInfo message:msg];
+ [logger logLevel:NGLogLevelInfo message:msg];
[msg release];
}
- (void)logWarnWithFormat:(NSString *)_fmt, ... {
+ NGLogger *logger;
NSString *msg;
va_list va;
+ logger = [self logger];
+ if(![logger isLogWarnEnabled])
+ return;
+
va_start(va, _fmt);
msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
va_end(va);
- [self logLevel:NGLogLevelWarn message:msg];
+ [logger logLevel:NGLogLevelWarn message:msg];
[msg release];
}
- (void)logErrorWithFormat:(NSString *)_fmt, ... {
+ NGLogger *logger;
NSString *msg;
va_list va;
+ logger = [self logger];
+ if(![logger isLogErrorEnabled])
+ return;
+
va_start(va, _fmt);
msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
va_end(va);
- [self logLevel:NGLogLevelError message:msg];
+ [logger logLevel:NGLogLevelError message:msg];
[msg release];
}
- (void)logFatalWithFormat:(NSString *)_fmt, ... {
+ NGLogger *logger;
NSString *msg;
va_list va;
-
+
+ logger = [self logger];
+ if(![logger isLogFatalEnabled])
+ return;
+
va_start(va, _fmt);
msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
va_end(va);
- [self logLevel:NGLogLevelFatal message:msg];
+ [logger logLevel:NGLogLevelFatal message:msg];
[msg release];
}
# version
-SUBMINOR_VERSION:=130
+SUBMINOR_VERSION:=131
# v4.3.115 requires libFoundation v1.0.59
# v4.2.72 requires libEOControl v4.2.39