From: helge Date: Fri, 19 Nov 2004 02:25:12 +0000 (+0000) Subject: subminor reformats X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ecb43a6a5c1eddb91c8b2321a9012210c4728355;p=sope subminor reformats git-svn-id: http://svn.opengroupware.org/SOPE/trunk@399 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-core/NGExtensions/FdExt.subproj/NSObject+Logs.m b/sope-core/NGExtensions/FdExt.subproj/NSObject+Logs.m index f6c77231..f1091470 100644 --- a/sope-core/NGExtensions/FdExt.subproj/NSObject+Logs.m +++ b/sope-core/NGExtensions/FdExt.subproj/NSObject+Logs.m @@ -47,6 +47,7 @@ static inline Class NSStringClass(void) { 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]]; } @@ -84,7 +85,7 @@ static inline Class NSStringClass(void) { logger = [self logger]; if (![logger isLogInfoEnabled]) return; - + msg = [[NSStringClass() alloc] initWithFormat:_fmt arguments:_va]; [logger logWithFormat:@"%@ %@", [self loggingPrefix], msg]; [msg release]; diff --git a/sope-core/NGExtensions/NGLogging.subproj/NGLogAppender.m b/sope-core/NGExtensions/NGLogging.subproj/NGLogAppender.m index 09260857..4ae5e3a7 100644 --- a/sope-core/NGExtensions/NGLogging.subproj/NGLogAppender.m +++ b/sope-core/NGExtensions/NGLogging.subproj/NGLogAppender.m @@ -41,7 +41,7 @@ lvl = [self localizedNameOfLogLevel:[_event level]]; fe = [NSMutableString stringWithCapacity:128]; - if(lvl) { + if (lvl != nil) { [fe appendString:@"["]; [fe appendString:lvl]; [fe appendString:@"] "]; diff --git a/sope-core/NGExtensions/NGLogging.subproj/NGLogConsoleAppender.m b/sope-core/NGExtensions/NGLogging.subproj/NGLogConsoleAppender.m index 8d285b42..ad624a25 100644 --- a/sope-core/NGExtensions/NGLogging.subproj/NGLogConsoleAppender.m +++ b/sope-core/NGExtensions/NGLogging.subproj/NGLogConsoleAppender.m @@ -1,23 +1,23 @@ /* - 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" @@ -25,7 +25,8 @@ @implementation NGLogConsoleAppender - (void)appendLogEvent:(NGLogEvent *)_event { + // TODO: broken, NSLog takes a format string NSLog([self formattedEvent:_event]); } -@end +@end /* NGLogConsoleAppender */ diff --git a/sope-core/NGExtensions/TODO b/sope-core/NGExtensions/TODO index 51a66399..e7296d9d 100644 --- a/sope-core/NGExtensions/TODO +++ b/sope-core/NGExtensions/TODO @@ -9,3 +9,48 @@ NSString+Encoding.m: - 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