if (logger == nil) {
NGLoggerManager *lm;
+ // TODO: broken. If [self class] is passed in, 'logger' can't be a static
lm = [NGLoggerManager defaultLoggerManager];
logger = [lm loggerForClass:[self class]];
}
logger = [self logger];
if (![logger isLogInfoEnabled]) return;
-
+
msg = [[NSStringClass() alloc] initWithFormat:_fmt arguments:_va];
[logger logWithFormat:@"%@ %@", [self loggingPrefix], msg];
[msg release];
/*
- Copyright (C) 2000-2004 SKYRIX Software AG
+ 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.
- */
+ 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 "NGLogConsoleAppender.h"
#include "NGLogEvent.h"
@implementation NGLogConsoleAppender
- (void)appendLogEvent:(NGLogEvent *)_event {
+ // TODO: broken, NSLog takes a format string
NSLog([self formattedEvent:_event]);
}
-@end
+@end /* NGLogConsoleAppender */
- add a "charset" encoding registry
- improve error handling
- improve buffer size handling
+
+NGLogger:
+
+- fix format bugs
+
+- fix performance
+ - running two format parsers and varargs processors is unnecessary
+ and far too expensive
+ - running seven methods calls just in logWithFormat:arguments: is expensive
+
+ - analysis: (for a simple logWithFormat:)
+ - NSObject logWithFormat:arguments:
+ - one format parser
+ - one varargs run
+ - 7 method calls
+ - NSObject logger
+ - caches in static variable, no method call after warm up
+ - NGLogger isLogInfoEnabled
+ - simple comparison (use macro or access public ivars?)
+ - NSObject loggingPrefix
+ - one autorelease string
+ - one format parser
+ - 2 method calls
+ - NGLogger logWithFormat:arguments:
+ - since we already know that logging is enabled, we do not need to check
+ again => forceLogWithPrefix:string: or -logLevel:message:
+ - one format parser
+ - one varargs run
+ - 4 method calls
+ - NGLogger logLevel:message:
+ - creates/releases a log event object
+ - calls appender
+ - 4 method calls
+ - NGLogConsoleAppender
+ - (incorrectly) calls NSLog => one varargs parser
+ - 1 method call
+ - NGLogAppender formattedEvent:
+ - 8 method calls
+ - creates an autorelease string
+ - NGLogAppender localizedNameOfLogLevel:
+ - simple switch
+ - summary: limit NGLogger to the few applications which require it
+
+- having -logWithFormat:arguments: on NSObject seems unnecessary, there is
+ no reason to override this method