/*
- Copyright (C) 2000-2004 SKYRIX Software AG
+ Copyright (C) 2000-2005 SKYRIX Software AG
- This file is part of OpenGroupware.org.
+ This file is part of SOPE.
- OGo is free software; you can redistribute it and/or modify it under
+ SOPE 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
+ SOPE 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
+ License along with SOPE; see the file COPYING. If not, write to the
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
@interface WOCoreApplication(PrivateMethods)
+ (void)_initDefaults;
++ (id)logger;
- (NSDictionary *)memoryStatistics;
- (WOResponse *)handleException:(NSException *)_exc;
@end
static BOOL outputValidateOn = NO;
static Class NSDateClass = Nil;
+static NGLogger *logger = nil;
static NGLogger *perfLogger = nil;
+ (int)version {
+ (id)application {
if (WOApp == nil) {
- [self logWarnWithFormat:@"(%s): some code called +application without an "
- @"active app !", __PRETTY_FUNCTION__];
+ [self warnWithFormat:@"%s: some code called +application without an "
+ @"active app !", __PRETTY_FUNCTION__];
#if DEBUG && 0
# warning REMOVE THAT ABORT IN PRODUCTION CODE !!!
abort();
unsigned idx;
if (WOApp != self) {
- [self logWithFormat:
+ [self warnWithFormat:
@"tried to deactivate inactive application !\n"
@" self: %@\n"
@" active: %@",
[self _initDefaults];
lm = [NGLoggerManager defaultLoggerManager];
+ logger = [lm loggerForClass:self];
perfLogger = [lm loggerForDefaultKey:@"WOProfileApplication"];
ud = [NSUserDefaults standardUserDefaults];
/* NGLogging */
++ (id)logger {
+ return logger;
+}
+
- (id)logger {
- static id sharedLogger = nil;
- if(sharedLogger == nil) {
- sharedLogger = [[NGLogger alloc] initWithLogLevel:NGLogLevelDebug];
- }
- return sharedLogger;
+ return logger;
}
/* signals */
adaptorClass = NSClassFromString(_name);
if (adaptorClass == Nil) {
- [self logWithFormat:@"ERROR: did not find adaptor class %@", _name];
+ [self errorWithFormat:@"did not find adaptor class %@", _name];
return nil;
}
WOResponse *r = nil;
if ([self respondsToSelector:@selector(handleException:)]) {
- [self logWarnWithFormat:@"calling deprecated -handleException method !"];
+ [self warnWithFormat:@"calling deprecated -handleException method !"];
return [self handleException:_exc];
}
#if 0 && DEBUG
- [self logWithFormat:@"%@: caught (without context):\n %@.", self, _exc];
+ [self errorWithFormat:@"%@: caught (without context):\n %@.", self, _exc];
abort();
#endif
if (_ctx == nil) {
- [self logWithFormat:@"%@: caught (without context):\n %@.", self, _exc];
+ [self errorWithFormat:@"%@: caught (without context):\n %@.",
+ self, _exc];
[self terminate];
}
else if (rq == nil) {
- [self logWithFormat:@"%@: caught (without request):\n %@.", self, _exc];
+ [self errorWithFormat:@"%@: caught (without request):\n %@.",
+ self, _exc];
[self terminate];
}
else {
}
if ((r = [WOResponse responseWithRequest:rq]) == nil)
- [self logWithFormat:@"could not create response !"];
+ [self warnWithFormat:@"could not create response !"];
[r setStatus:500];
return r;
adaptor = [self adaptorWithName:[moreAdaptors objectAtIndex:i]
arguments:nil];
if (adaptor == nil) {
- [self logWithFormat:@"could not find WOAdaptor '%@' !",
+ [self warnWithFormat:@"could not find WOAdaptor '%@' !",
[moreAdaptors objectAtIndex:i]];
continue;
}
static BOOL didWarn = NO;
if (!didWarn) {
- [self logWithFormat:
- @"WARNING: output validation is enabled, this will "
+ [self warnWithFormat:
+ @"output validation is enabled, this will "
@"slow down request processing!"];
didWarn = YES;
}
if ([self hideValidationIssue:issue])
continue;
[self logWithFormat:@"validate-output[%@]: %@",
- [(NSException *)issue name], [issue reason]];
+ [(NSException *)issue name], [issue reason]];
continue;
}
if (perfLogger) {
NSTimeInterval rt;
rt = [[NSDateClass date] timeIntervalSince1970] - startDispatch;
- [perfLogger logInfoWithFormat:@"[woapp-rq]: request handler took %4.3fs.",
+ [perfLogger logWithFormat:@"[woapp-rq]: request handler took %4.3fs.",
rt < 0.0 ? -1.0 : rt];
}
}
if (perfLogger) {
NSTimeInterval rt;
rt = [[NSDateClass date] timeIntervalSince1970] - startDispatch;
- [perfLogger logInfoWithFormat:@"[woapp]: dispatchRequest took %4.3fs.",
- rt < 0.0 ? -1.0 : rt];
+ [perfLogger logWithFormat:@"[woapp]: dispatchRequest took %4.3fs.",
+ rt < 0.0 ? -1.0 : rt];
}
return response;
WORequestHandler *handler;
if ([self respondsToSelector:@selector(handleRequest:)]) {
- [self logWarnWithFormat:
+ [self warnWithFormat:
@"calling deprecated -handleRequest: method .."];
return [self handleRequest:_request];
}
/* find request handler for request */
if ((handler = [self handlerForRequest:_request]) == nil) {
- [self logErrorWithFormat:@"got no request handler for request: %@ !",
+ [self errorWithFormat:@"got no request handler for request: %@ !",
_request];
return nil;
}
apath = [self findNGObjWebResource:@"Defaults" ofType:@"plist"];
if (apath == nil)
- [self logErrorWithFormat:@"cannot find Defaults.plist resource of NGObjWeb library!"];
+ [self errorWithFormat:@"cannot find Defaults.plist resource of NGObjWeb library!"];
#if HEAVY_DEBUG
else
- [self logDebugWithFormat:@"Note: loading default defaults: %@", apath];
+ [self debugWithFormat:@"Note: loading default defaults: %@", apath];
#endif
owDefaults = [NSDictionary dictionaryWithContentsOfFile:apath];
if (owDefaults) {
[[NSUserDefaults standardUserDefaults] registerDefaults:owDefaults];
#if HEAVY_DEBUG
- [self logDebugWithFormat:@"did register NGObjWeb defaults: %@\n%@",
- apath, owDefaults];
+ [self debugWithFormat:@"did register NGObjWeb defaults: %@\n%@",
+ apath, owDefaults];
#endif
}
else {
- [self logErrorWithFormat:@"could not load NGObjWeb defaults: '%@'",
+ [self errorWithFormat:@"could not load NGObjWeb defaults: '%@'",
apath];
}
}
if ([addr isKindOfClass:[NGInternetSocketAddress class]])
return [NSNumber numberWithInt:[(NGInternetSocketAddress *)addr port]];
- [self logFatalWithFormat:@"GOT NO PORT FOR ADDR: %@ (%@)", addr, woport];
+ [self fatalWithFormat:@"GOT NO PORT FOR ADDR: %@ (%@)", addr, woport];
return nil;
}