Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WOKeyPathAssociation.m 1 2004-08-20 10:08:27Z znek $
#include "WOKeyPathAssociation.h"
#include <NGObjWeb/WOComponent.h>
if ([_keyPath length] < 1) {
self = [self autorelease];
self = nil;
- NSLog(@"ERROR: passed invalid keypath (%@) to association !", _keyPath);
+ [self errorWithFormat:
+ @"passed invalid keypath (%@) to association !", _keyPath];
return nil;
}
if ((self = [super init])) {
withDefaultValue:(NSString *)_default
{
if ([_key length] == 0) {
- [self debugWithFormat:@"WARNING: missing label key!"];
+ [self warnWithFormat:@"missing label key!"];
[self release];
return nil;
}
if ((rm = [_component resourceManager]) == nil)
rm = [[WOApplication application] resourceManager];
if (rm == nil)
- [self debugWithFormat:@"WARNING: missing resource manager!"];
+ [self warnWithFormat:@"missing resource manager!"];
/* get parameters */
- (id)initWithString:(NSString *)_name {
if ([_name length] == 0) {
if (doDebug) {
- NSLog(@"WARNING(%s): got passed no resource name!",
- __PRETTY_FUNCTION__);
+ [self warnWithFormat:@"(%s): got passed no resource name!",
+ __PRETTY_FUNCTION__];
}
[self release];
return nil;
rm = [app resourceManager];
}
if (rm == nil) {
- [self logWithFormat:@"WARNING: found no resource manager!"];
+ [self warnWithFormat:@"found no resource manager!"];
return nil;
}
if (doDebug) [self debugWithFormat:@" resource-manager: %@", rm];
#include <NGExtensions/NGExtensions.h>
#define IS_DEPRECATED \
- NSLog(@"WARNING: used deprecated method: %s:%i.", \
- __PRETTY_FUNCTION__, __LINE__);
+ [self warnWithFormat:@"used deprecated method: %s:%i.", \
+ __PRETTY_FUNCTION__, __LINE__];
+2004-11-18 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * v4.5.91
+
+ * Associations/{WOKeyPathAssociation.m, WOLabelAssociation.m,
+ WOResourceURLAssociation.m, common.h},
+ DynamicElements/{WOForm.m, WOGenericElement.m, WOImage.m,
+ WOPopUpButton.m, WOString.m, WOxHTMLElemBuilder.m,
+ WOxMiscElemBuilder.m, _WOTemporaryHyperlink.m},
+ NGObjWeb/WOxElemBuilder.h,
+ SoObjects/{SoActionInvocation.m, SoClassSecurityInfo.m,
+ SoComponent.m, SoObject+Traversal.m, SoObject.m,
+ SoObjectRequestHandler.m, SoObjectSOAPDispatcher.m,
+ SoObjectXmlRpcDispatcher.m, SoPageInvocation.m, SoProduct.m,
+ SoProductClassInfo.m, SoProductRegistry.m,
+ SoProductResourceManager.m, SoSelectorInvocation.m},
+ Templates/{WOApplication+Builders.m, WOComponentScriptPart.m,
+ WODParser.m, WOHTMLParser.m, WOWrapperTemplateBuilder.m,
+ WOxComponentElemBuilder.m, WOxElemBuilder.m, common.h},
+ WebDAV/{SaxDAVHandler.m, SoDAVSQLParser.m, SoObject+SoDAV.m,
+ SoObject+SoDAVQuery.m, SoObjectWebDAVDispatcher.m,
+ SoWebDAVRenderer.m},
+ WOHttpAdaptor/{WOHttpAdaptor.m, WOHttpTransaction.m,
+ WORequestParser.m},
+ NGHttp+WO.m, OWResourceManager.m, SNSConnection.m,
+ WEClientCapabilities.m, WOApplication.m, WOChildComponentReference.m,
+ WOComponent.m, WOComponentDefinition.m, WOComponentRequestHandler.m,
+ WOContext.m, WOCoreApplication+Bundle.m, WOCoreApplication.m,
+ WODirectAction.m, WODirectActionRequestHandler.m, WODisplayGroup.m,
+ WODynamicElement.m, WOElementID.m, WOFileSessionStore.m,
+ WOMessage.m, WOPageRequestHandler.m, WORequest.m, WORequestHandler.m,
+ WOResourceManager.m, WORunLoop.m, WOServerSessionStore.m,
+ WOSimpleHTTPParser.m, _WOStringTable.m, common.h:
+ changed to use new logging API, various code cleanup.
+
+ * WOHttpAdaptor/WOHttpAdaptor.m:
+
+ * NGObjWeb.xcode, SoObjects/SoObjects.xcode, WebDAV/WebDAV.xcode:
+ bumped framework version
+
2004-11-18 Helge Hess <helge.hess@opengroupware.org>
* WORequestHandler.m: removed double click hack, not necessary anymore
used as the path for the session-id cookie (related to OGo bug #914
(v4.5.89)
-2004-11-05 Helge Hess <helge.hess@skyrix.com>
+2004-11-15 Helge Hess <helge.hess@skyrix.com>
* WOSimpleHTTPParser.m: set a default file boundary size and max upload
size if the Defaults.plist was not loaded (eg in xmlrpc_call with
}
if ([_ctx isInForm]) {
- NSLog(@"ERROR(%s): another form is already active in context !",
- __PRETTY_FUNCTION__);
+ [self errorWithFormat:@"(%s): another form is already active in context !",
+ __PRETTY_FUNCTION__];
}
[_ctx setInForm:YES];
if (![_ctx isInForm]) {
[[_ctx component]
- logWithFormat:@"ERROR(%s:%d): -isInForm is NO !!!",
+ errorWithFormat:@"(%s:%d): -isInForm is NO !!!",
__PRETTY_FUNCTION__, __LINE__];
}
else
if (self->tagName) free(self->tagName);
break;
default:
- NSLog(@"ERROR: unknown tag-name-type %i !", self->tagNameType);
+ [self errorWithFormat:@"unknown tag-name-type %i !", self->tagNameType];
break;
}
[super dealloc];
}
- (void)dealloc {
- NSLog(@"ERROR: called dealloc on %@", self);
+ [self errorWithFormat:@"called dealloc on %@", self];
#if DEBUG
abort();
#endif
@"Note: template uses deprecated 'singleSelection' binding!"];
}
else {
- [self debugWithFormat:
- @"ERROR: 'singleSelection' binding is set to NO, which is "
- @"unsupported now!"];
+ [self errorWithFormat:
+ @"'singleSelection' binding is set to NO, which is "
+ @"unsupported now!"];
}
}
else {
- [self logWithFormat:
- @"ERROR: will ignore deprecated 'singleSelection' binding: %@",
- tmp];
+ [self errorWithFormat:
+ @"will ignore deprecated 'singleSelection' binding: %@", tmp];
}
[tmp release];
}
}
- (void)dealloc {
- NSLog(@"ERROR: called dealloc on %@", self);
+ [self errorWithFormat:@"called dealloc on %@", self];
#if DEBUG
abort();
#endif
else if (c1 == 'h' && [type isEqualToString:@"hidden"])
return NSClassFromString(@"WOHiddenField");
else if (c1 == 'b' && [type isEqualToString:@"button"]) {
- [self logWithFormat:@"WARNING: selecting WOSubmitButton for "
- @"input with type 'button' !"];
+ [self warnWithFormat:@"selecting WOSubmitButton for "
+ @"input with type 'button' !"];
return NSClassFromString(@"WOSubmitButton");
}
break;
break;
}
- [self logWithFormat:@"WARNING: unknown input type '%@' !", type];
+ [self warnWithFormat:@"unknown input type '%@' !", type];
return NSClassFromString(@"WOTextField");
}
case 'n':
if ([tag isEqualToString:@"nbsp"]) {
- NSLog(@"WARNING(%s): found <var:nbsp/>, "
- @"use <var:entity name='nbsp'/> !",
- __PRETTY_FUNCTION__);
+ [self warnWithFormat:@"%s: found <var:nbsp/>, "
+ @"use <var:entity name='nbsp'/> !",
+ __PRETTY_FUNCTION__];
return NSClassFromString(@"WOEntity");
}
break;
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: _WOTemporaryHyperlink.m 1 2004-08-20 10:08:27Z znek $
#include "WOHyperlink.h"
#include "WOHyperlinkInfo.h"
}
- (void)dealloc {
- NSLog(@"ERROR: called dealloc on %@", self);
+ [self errorWithFormat:@"called dealloc on %@", self];
#if DEBUG
abort();
#endif
/* transfer cookies */
if ([[_request cookies] count] > 0)
- NSLog(@"WARNING: cannot transfer cookies to NGHttpRequest yet !");
+ [self warnWithFormat:@"cannot transfer cookies to NGHttpRequest yet !"];
/* transfer headers !!! */
ebody = [self body];
if (![ebody isKindOfClass:[NGMimeMultipartBody class]]) {
- [self logWithFormat:
- @"ERROR: form-data parser expected MultipartBody, got %@", ebody];
+ [self errorWithFormat:
+ @"form-data parser expected MultipartBody, got %@", ebody];
return [[NGHashMap alloc] init];
}
[[bodyPart valuesOfHeaderFieldWithName:@"content-disposition"]nextObject];
if (disposition == nil) {
- [self logWithFormat:
- @"ERROR: did not find content disposition in form part %@",
- bodyPart];
+ [self errorWithFormat:
+ @"did not find content disposition in form part %@", bodyPart];
continue;
}
+2004-11-18 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * NGHttp.xcode: bumped the framework version
+
2004-11-07 Marcus Mueller <znek@mulle-kybernetik.com>
* NGHttp.xcode: bumped the framework version
);
buildSettings = {
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 4.5.84;
+ DYLIB_CURRENT_VERSION = 4.5.91;
FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks";
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
);
buildSettings = {
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 4.5.84;
+ DYLIB_CURRENT_VERSION = 4.5.91;
FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks";
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WOxElemBuilder.h 1 2004-08-20 10:08:27Z znek $
#ifndef __WOxElemBuilder_H__
#define __WOxElemBuilder_H__
/* logging */
+/*
- (void)logWithFormat:(NSString *)_format, ...;
- (void)debugWithFormat:(NSString *)_format, ...;
+*/
/* managing builder queues */
fm = [self fileManager];
if ([self->base length] > 0) {
if (![fm fileExistsAtPath:self->base]) {
- NSLog(@"WARNING(%s): Resources base path '%@' does not exist !",
- __PRETTY_FUNCTION__, self->base);
+ [self warnWithFormat:@"(%s): Resources base path '%@' does not exist !",
+ __PRETTY_FUNCTION__, self->base];
return nil;
}
}
if ([self->resources length] > 0) {
if (![fm fileExistsAtPath:self->resources]) {
- [self debugWithFormat:
- @"WARNING(%s): Resources path %@ does not exist !",
+ [self warnWithFormat:
+ @"(%s): Resources path %@ does not exist !",
__PRETTY_FUNCTION__, self->resources];
[self->resources release]; self->resources = nil;
}
static BOOL didLog = NO;
if (!didLog) {
didLog = YES;
- [self debugWithFormat:
- @"WARNING(%s): WebServerResources path '%@' does not exist !",
+ [self warnWithFormat:
+ @"(%s): WebServerResources path '%@' does not exist !",
__PRETTY_FUNCTION__, self->w3resources];
}
[self->w3resources release]; self->w3resources = nil;
languages:(NSArray *)_langs
{
/* search for component wrapper .. */
- // TODO: shouldn't we used that for WOx as well?
+ // TODO: shouldn't we use that for WOx as well?
NSEnumerator *e;
NSString *ext;
if (_name == nil) {
#if DEBUG
- NSLog(@"WARNING(%s): tried to get path to component with <nil> name !",
- __PRETTY_FUNCTION__);
+ [self warnWithFormat:@"(%s): tried to get path to component with "
+ @"<nil> name !",
+ __PRETTY_FUNCTION__];
#endif
return nil;
}
}
if (!isDirectory) {
- NSLog(@"WARNING(%s): language entry %@ is not a directory !",
- __PRETTY_FUNCTION__, languagePath);
+ [self warnWithFormat:@"(%s): language entry %@ is not a directory !",
+ __PRETTY_FUNCTION__, languagePath];
if (doesCache && (compoundKey != nil)) {
// register null in cache, so that we know it's non-existent
NSMapInsert(self->componentDefinitions, compoundKey, null);
baseURL:[NSURL URLWithString:baseUrl]
frameworkName:nil];
if (cdef == nil) {
- NSLog(@"WARNING(%s): could not load component definition of "
- @"'%@' from language project: %@",
- __PRETTY_FUNCTION__, _name, languagePath);
+ [self warnWithFormat:@"(%s): could not load component definition of "
+ @"'%@' from language project: %@",
+ __PRETTY_FUNCTION__, _name, languagePath];
if (doesCache && (compoundKey != nil)) {
// register null in cache, so that we know it's non-existent
NSMapInsert(self->componentDefinitions, compoundKey, null);
baseURL:[NSURL URLWithString:baseUrl]
frameworkName:nil];
if (cdef == nil) {
- NSLog(@"WARNING(%s): could not load component definition of '%@' from "
- @"component wrapper: '%@'",
- __PRETTY_FUNCTION__, _name, componentURL);
+ [self warnWithFormat:@"(%s): could not load component definition of "
+ @"'%@' from component wrapper: '%@'",
+ __PRETTY_FUNCTION__, _name, componentURL];
if (doesCache) {
/* register null in cache, so that we know it's non-existent */
NSMapInsert(self->componentDefinitions, componentURL, null);
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: SNSConnection.m 14 2004-08-20 21:07:18Z helge $
#include "SNSConnection.h"
#include <NGObjWeb/WOApplication.h>
sns = NGSocketAddressFromString([ud stringForKey:@"SNSPort"]);
if (sns == nil) {
- NSLog(@"ERROR(%s): Could not create socket address for snsd(port=%@).",
- __PRETTY_FUNCTION__, sns);
+ [self errorWithFormat:
+ @"(%s): Could not create socket address for snsd(port=%@).",
+ __PRETTY_FUNCTION__, sns];
RELEASE(self);
return;
}
#endif
if (![self->socket isConnected]) {
- NSLog(@"ERROR: Could not connect socket %@ to snsd (port=%@), "
- @"terminating: %@", self->socket, sns, [self->socket lastException]);
+ [self errorWithFormat:@"Could not connect socket %@ to snsd (port=%@), "
+ @"terminating: %@",
+ self->socket, sns, [self->socket lastException]];
ASSIGN(self->socket, (id)nil);
RELEASE(self);
[[WOApplication application] terminate];
NS_ENDHANDLER;
if (self->socket == nil) {
- NSLog(@"ERROR: Could not register with snsd (port=%@).", sns);
+ [self errorWithFormat:@"Could not register with snsd (port=%@).", sns];
RELEASE(self);
return;
}
}
- (void)lostConnectionToNameServer:(NSException *)_exception {
- NSLog(@"ERROR: application lost connection to snsd: %@", _exception);
+ [self errorWithFormat:@"application lost connection to snsd: %@", _exception];
[[WOApplication application] terminate];
}
- (void)lostConnectionToNameServer {
// TODO: I guess that should be improved a bit in the dispatcher
if ((soapEnvelope = [_ctx valueForKey:@"SOAPEnvelope"]) == nil) {
// TODO: generate some kind of fault? (NSException?)
- [self logWithFormat:@"ERROR: no SOAP envelope available in context!"];
+ [self errorWithFormat:@"no SOAP envelope available in context!"];
return nil;
}
if ([_type isEqualToString:@"SOAP"])
return [self extractSOAPArgumentsFromContext:_ctx specification:_spec];
- [self logWithFormat:
- @"ERROR: cannot extract parameters for request type: '%@'", _type];
+ [self errorWithFormat:
+ @"cannot extract parameters for request type: '%@'", _type];
return nil;
}
/* find class */
if ((clazz = NSClassFromString([self actionClassName])) == Nil) {
- [self logWithFormat:@"ERROR: did not find action class: %@",
- [self actionClassName]];
+ [self errorWithFormat:@"did not find action class: %@",
+ [self actionClassName]];
return nil;
}
infoCount = [info count];
argCount = [_args count];
if ((info == nil) && (argCount > 0)) {
- [self logWithFormat:
- @"WARNING: found no argument specification for positional keys!"];
+ [self warnWithFormat:
+ @"found no argument specification for positional keys!"];
return;
}
for (i = 0; i < argCount; i++) {
if (i >= infoCount) {
- [self logWithFormat:
- @"WARNING: could not apply argument %d (no key info)", (i + 1)];
+ [self warnWithFormat:
+ @"could not apply argument %d (no key info)", (i + 1)];
continue;
}
inv->methodObject = [[inv instantiateMethodInContext:_ctx] retain];
if (inv->methodObject == nil) {
- [self logWithFormat:@"ERROR: did not find method '%@'",
- [self actionClassName]];
+ [self errorWithFormat:@"did not find method '%@'", [self actionClassName]];
return nil;
}
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: SoClassSecurityInfo.m 1 2004-08-20 10:08:27Z znek $
#include "SoClassSecurityInfo.h"
#include "SoClass.h"
/* attribute security */
- (void)_logPermAlreadySetForName:(NSString *)_name {
- [self logWithFormat:
- @"WARNING: tried to declare permission for attribute '%@' twice!",
- _name];
+ [self warnWithFormat:
+ @"tried to declare permission for attribute '%@' twice!", _name];
}
- (void)setDefaultAccess:(NSString *)_access {
/* object security */
- (void)_logObjPermAlreadySet {
- [self logWithFormat:
- @"WARNING: tried to declare object permission twice! "
- @"(perm=%@,private=%s,public=%s)",
- self->objectPermission,
- self->isObjectPrivate?"yes":"no",
- self->isObjectPublic?"yes":"no"];
+ [self warnWithFormat:@"tried to declare object permission twice! "
+ @"(perm=%@,private=%s,public=%s)",
+ self->objectPermission,
+ self->isObjectPrivate?"yes":"no",
+ self->isObjectPublic?"yes":"no"];
}
- (BOOL)hasObjectProtections {
self->defRoles = [[NSMutableDictionary alloc] initWithCapacity:8];
if ((tmp = [self->defRoles objectForKey:_per])) {
- [self logWithFormat:@"WARNING: tried to set default role of '%@' twice!"
- @" (set to %@)", _per, tmp];
+ [self warnWithFormat:@"tried to set default role of '%@' twice!"
+ @" (set to %@)", _per, tmp];
return;
}
self->defRoles = [[NSMutableDictionary alloc] initWithCapacity:8];
if ((tmp = [self->defRoles objectForKey:_p])) {
- [self logWithFormat:@"WARNING: tried to set default role of '%@' twice!"
- @" (set to %@)", _p, tmp];
+ [self warnWithFormat:@"tried to set default role of '%@' twice!"
+ @" (set to %@)", _p, tmp];
return;
}
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: SoComponent.m 1 2004-08-20 10:08:27Z znek $
#include "SoComponent.h"
#include "SoProductResourceManager.h"
if (reg == nil)
reg = [[SoProductRegistry sharedProductRegistry] retain];
if (reg == nil)
- [self logWithFormat:@"ERROR: missing product registry!"];
+ [self errorWithFormat:@"missing product registry!"];
if ((bundle = [self componentBundle]) == nil)
- [self logWithFormat:@"WARNING: did not find bundle of component !"];
+ [self warnWithFormat:@"did not find bundle of component !"];
if ((product = [reg productForBundle:bundle]) == nil)
- [self logWithFormat:
- @"WARNING: did not find product of component (bundle=%@)", bundle];
+ [self warnWithFormat:@"did not find product of component (bundle=%@)",
+ bundle];
return product;
}
tmpl = [self templateWithName:[self name]];
if (tmpl == nil) {
- [self logWithFormat:
- @"WARNING: found not template named '%@' for component.",
- [self name]];
+ [self warnWithFormat:@"found not template named '%@' for component.",
+ [self name]];
}
return tmpl;
}
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: SoObject+Traversal.m 1 2004-08-20 10:08:27Z znek $
#include "SoObjectRequestHandler.h"
#include "SoObject.h"
return [self traversePathArray:_tp acquire:_acquire];
}
- [self logWithFormat:
- @"ERROR(%s): don't know how to turn path object %@ into an array",
- __PRETTY_FUNCTION__, _tp];
+ [self errorWithFormat:
+ @"(%s): don't know how to turn path object %@ into an array",
+ __PRETTY_FUNCTION__, _tp];
return nil;
}
NSString *name;
if (parent == self) {
- [self logWithFormat:
- @"WARNING: container==object in baseURL calculation (loop?): %@",
- self];
+ [self warnWithFormat:
+ @"container==object in baseURL calculation (loop?): %@",
+ self];
}
baseURL = [parent baseURLInContext:_ctx];
if (port == 0) {
static BOOL didWarn = NO;
if (!didWarn) {
- [self logWithFormat:
- @"WARNING(%s:%i): got an empty port, probably buggy "
- @"SOUP host header!",
- __PRETTY_FUNCTION__, __LINE__];
+ [self warnWithFormat:@"(%s:%i): got an empty port, probably buggy "
+ @"SOAP host header!",
+ __PRETTY_FUNCTION__, __LINE__];
didWarn = YES;
}
port = 23000;
dpClass = [self->dispatcherRules valueForKey:@"dispatcher"];
rqType = [self->dispatcherRules valueForKey:@"requestType"];
if (debugRulesOn) {
- [self debugWithFormat:@" selected dispatcher: %@", dpClass];
- [self debugWithFormat:@" selected rq-type: %@", rqType];
+ [self debugWithFormat:@"selected dispatcher: %@", dpClass];
+ [self debugWithFormat:@"selected rq-type: %@", rqType];
}
/* create dispatcher */
if (rqType != nil) [_ctx setSoRequestType:rqType];
if ((dispatcher = NSClassFromString(dpClass)) == nil) {
- [self logWithFormat:@"ERROR: did not find dispatcher class '%@'", dpClass];
+ [self errorWithFormat:@"did not find dispatcher class '%@'", dpClass];
return nil;
}
NSEnumerator *e;
id container;
- [self debugWithFormat:@" render in ctx: %@", _ctx];
+ [self debugWithFormat:@"render in ctx: %@", _ctx];
if ([_object isKindOfClass:[WOResponse class]])
/* already rendered ... */
if ((renderer = [container rendererForObject:_object inContext:_ctx])) {
/* the container provided an own renderer for the object */
- [self debugWithFormat:@" use container renderer: %@", renderer];
+ [self debugWithFormat:@"use container renderer: %@", renderer];
break;
}
}
Class clazz;
if ((clazz = NSClassFromString(rendererClass)) == Nil) {
- [self logWithFormat:@"did not find class of selected renderer %@",
+ [self errorWithFormat:@"did not find class of selected renderer %@",
rendererClass];
}
else if ((renderer = [clazz sharedRenderer]) == nil) {
- [self logWithFormat:@"could not get renderer of class %@",
+ [self errorWithFormat:@"could not get renderer of class %@",
rendererClass];
}
else if (![renderer canRenderObject:_object inContext:_ctx]) {
}
if (renderer)
- [self debugWithFormat:@" use rule-selected renderer: %@", renderer];
+ [self debugWithFormat:@"use rule-selected renderer: %@", renderer];
}
if (renderer == nil)
- [self debugWithFormat:@" found no renderer for object: %@", _object];
+ [self debugWithFormat:@"found no renderer for object: %@", _object];
if ((error = [renderer renderObject:_object inContext:_ctx])) {
if (renderer != [SoDefaultRenderer sharedRenderer]) {
e2 = [(SoDefaultRenderer *)[SoDefaultRenderer sharedRenderer]
renderObject:error inContext:_ctx];
if (e2) {
- [self logWithFormat:@"default renderer could not render error %@: %@",
- error, e2];
+ [self errorWithFormat:
+ @"default renderer could not render error %@: %@", error, e2];
return nil;
}
}
else {
- [self logWithFormat:@"default renderer returned error: %@", error];
+ [self errorWithFormat:@"default renderer returned error: %@", error];
return nil;
}
}
if (debugOn) {
[self debugWithFormat:@"request 0x%08X: %@ %@ (ctx=0x%08X)", _rq,
[_rq method], [_rq uri], _ctx];
- if (_sn) [self debugWithFormat:@" session 0x%08X: %@", _sn, _sn];
+ if (_sn) [self debugWithFormat:@"session 0x%08X: %@", _sn, _sn];
}
/* setup rule context */
[self debugWithFormat:@"authenticator allowed request."];
}
else {
- [self debugWithFormat:@"WARNING: no authenticator available."];
+ [self warnWithFormat:@"no authenticator available."];
}
/* lookup object */
if ([object isKindOfClass:[NSException class]]) {
/* exceptions are not called ... */
- [self debugWithFormat:@" not calling exception: %@", object];
+ [self debugWithFormat:@"not calling exception: %@", object];
doDispatch = NO;
}
id dispatcher;
dispatcher = [self dispatcherForObject:object inContext:_ctx];
- [self debugWithFormat:@" dispatcher: %@", dispatcher];
+ [self debugWithFormat:@"dispatcher: %@", dispatcher];
- [self debugWithFormat:@" dispatch object: %@", object];
+ [self debugWithFormat:@"dispatch object: %@", object];
object = [dispatcher dispatchInContext:_ctx];
if (object) [self->dispatcherRules takeValue:object forKey:@"result"];
/* render result */
if (object == nil) {
- [self debugWithFormat:@" got an empty result !"];
+ [self debugWithFormat:@"got an empty result !"];
r = [_ctx response];
[r setStatus:500];
[r appendContentString:@"the called object returned no result"];
else if ([object isKindOfClass:[WOResponse class]]) {
r = object;
[self debugWithFormat:
- @" got response: 0x%08X (status=%i,len=%@,type=%@)",
- r, [r status],
- [r headerForKey:@"content-length"],
- [r headerForKey:@"content-type"]];
+ @"got response: 0x%08X (status=%i,len=%@,type=%@)",
+ r, [r status],
+ [r headerForKey:@"content-length"],
+ [r headerForKey:@"content-type"]];
}
else {
if (debugOn) {
if ([object isKindOfClass:[NSData class]]) {
- [self debugWithFormat:@" render data 0x%08X[len=%i]",
+ [self debugWithFormat:@"render data 0x%08X[len=%i]",
object, [object length]];
}
else
- [self debugWithFormat:@" render object: %@", object];
+ [self debugWithFormat:@"render object: %@", object];
}
[self->dispatcherRules takeValue:object forKey:@"result"];
if (debugOn) {
[self debugWithFormat:
- @" made response: 0x%08X (status=%i,len=%@,type=%@)",
- r, [r status],
- [r headerForKey:@"content-length"],
- [r headerForKey:@"content-type"]];
+ @"made response: 0x%08X (status=%i,len=%@,type=%@)",
+ r, [r status],
+ [r headerForKey:@"content-length"],
+ [r headerForKey:@"content-type"]];
}
}
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: SoObjectSOAPDispatcher.m 1 2004-08-20 10:08:27Z znek $
#include "SoObjectSOAPDispatcher.h"
#include "SoObject.h"
}
if (methodObject == nil) {
- [self debugWithFormat:@"WARNING: could not locate SOAP method: %@",
- _actionName];
+ [self warnWithFormat:@"could not locate SOAP method: %@",
+ _actionName];
return [NSException exceptionWithHTTPStatus:501 /* not implemented */
reason:@"did not find the specified SOAP method"];
}
else if (![methodObject isCallable]) {
- [self debugWithFormat:
- @"WARNING: object found for SOAP method '%@' is not callable: "
- @"%@", _actionName, methodObject];
+ [self warnWithFormat:
+ @"object found for SOAP method '%@' is not callable: "
+ @"%@", _actionName, methodObject];
return [NSException exceptionWithHTTPStatus:501 /* not implemented */
reason:@"did not find the specified SOAP method"];
}
list = [envelope getElementsByTagName:@"Header"];
// TODO: not yet supported by DOMElement: namespaceURI:XMLNS_SOAP_ENVELOPE];
if ([list length] > 1) {
- [self logWithFormat:
- @"WARNING: multiple SOAP headers in request?! (using first)"];
+ [self warnWithFormat:@"multiple SOAP headers in request?! (using first)"];
}
header = [list length] > 0 ? [list objectAtIndex:0] : nil;
if (debugParsing) [self debugWithFormat:@"header: %@", header];
reason:@"could not parse SOAP body of request"];
}
else if ([list length] > 1) {
- [self logWithFormat:
- @"WARNING: multiple SOAP bodies in request?! (using first)"];
+ [self warnWithFormat:@"multiple SOAP bodies in request?! (using first)"];
}
body = [list objectAtIndex:0];
if (debugParsing) [self debugWithFormat:@"body: %@", body];
pool = [[NSAutoreleasePool alloc] init];
if ((rq = [_ctx request]) == nil) {
- [self logWithFormat:@"ERROR: missing request in context!"];
+ [self errorWithFormat:@"missing request in context!"];
return nil;
}
SOAPAction = [rq headerForKey:@"soapaction"];
if ([SOAPAction length] == 0) {
- [self logWithFormat:@"ERROR: missing SOAPAction HTTP header!"];
+ [self errorWithFormat:@"missing SOAPAction HTTP header!"];
return nil;
}
}
if ([_params count] > 0) {
- [self logWithFormat:
- @"WARNING: invoking SOPE method via XML-RPC without "
- @"positional paramters (%i parameters defined): %@",
- [_params count], method];
+ [self warnWithFormat:
+ @"invoking SOPE method via XML-RPC without "
+ @"positional paramters (%i parameters defined): %@",
+ [_params count], method];
}
return [method callOnObject:clientObject inContext:_ctx];
}
if (![XmlRpcMethodCall
instancesRespondToSelector:@selector(initWithRequest:)]) {
- [self logWithFormat:
- @"ERROR: XmlRpcMethodCall does not respond to -initWithRequest:, "
+ [self errorWithFormat:
+ @"XmlRpcMethodCall does not respond to -initWithRequest:, "
@"this method is part of libNGXmlRpc which you might want to link "
@"against to get XML-RPC support."];
return [NSException exceptionWithHTTPStatus:501 /* Not Implemented */
);
buildSettings = {
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 4.5.84;
+ DYLIB_CURRENT_VERSION = 4.5.91;
FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks";
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = NO;
inv->methodObject = [[inv instantiateMethodInContext:_ctx] retain];
if (inv->methodObject == nil) {
- [self logWithFormat:@"ERROR: did not find method '%@'",
- [self actionClassName]];
+ [self errorWithFormat:@"did not find method '%@'", [self actionClassName]];
return nil;
}
return inv;
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: SoProduct.m 1 2004-08-20 10:08:27Z znek $
#include "SoProduct.h"
#include "SoProductClassInfo.h"
return;
}
if ([self->categories objectForKey:_name]) {
- [self logWithFormat:
- @"ERROR: duplicate declaration of category on '%@' in product.",
- _name];
+ [self errorWithFormat:
+ @"duplicate declaration of category on '%@' in product.",
+ _name];
[catInfo release];
return;
}
return;
}
if ([self->classes objectForKey:_name]) {
- [self logWithFormat:
- @"ERROR: duplicate declaration of class %@ in product "
- @"(registering as category)",
- _name];
+ [self errorWithFormat:@"duplicate declaration of class %@ in product "
+ @"(registering as category)",
+ _name];
[classInfo release];
[self registerCategoryNamed:_name info:_info];
return;
return [[WOApplication application] resourceManager];
if (self->resourceManager == nil) {
- [self logWithFormat:@"WARNING: resource-manager was nil ..."];
+ [self warnWithFormat:@"resource-manager was nil ..."];
self->resourceManager =
[[SoProductResourceManager alloc] initWithProduct:self];
}
/* if an implementation was provided, register it with the class */
if ([_soClass valueForSlot:slotName]) {
- [self logWithFormat:@"WARNING: redefining slot '%@' of class '%@'",
+ [self warnWithFormat:@"redefining slot '%@' of class '%@'",
slotName, _soClass];
}
NSException *error;
if (_soClass == nil) {
- [self logWithFormat:@"ERROR(%s): missing soClass parameter?!",
+ [self errorWithFormat:@"(%s): missing soClass parameter?!",
__PRETTY_FUNCTION__];
return;
}
if (_registry == nil) {
- [self logWithFormat:@"ERROR: missing registry ?!"];
+ [self errorWithFormat:@"missing registry ?!"];
return;
}
e = [self->extensions objectEnumerator];
while ((ext = [e nextObject])) {
if ((error = [_registry registerSoClass:_soClass forExtension:ext])) {
- [self logWithFormat:
- @"ERROR: failed to register class %@ for extension %@: %@",
+ [self errorWithFormat:
+ @"failed to register class %@ for extension %@: %@",
[_soClass className], ext, error];
}
else if (loadDebugOn) {
e = [self->exactFilenames objectEnumerator];
while ((ext = [e nextObject])) {
if ((error = [_registry registerSoClass:_soClass forExactName:ext])) {
- [self logWithFormat:
- @"ERROR: failed to register class %@ for name %@: %@",
+ [self errorWithFormat:
+ @"failed to register class %@ for name %@: %@",
[_soClass className], ext, error];
}
else if (loadDebugOn) {
id security;
if (_registry == nil) {
- [self logWithFormat:@"WARNING(%s): did not pass a registry?!",
- __PRETTY_FUNCTION__];
+ [self warnWithFormat:@"(%s): did not pass a registry?!",
+ __PRETTY_FUNCTION__];
return;
}
if ((soClass = [_registry soClassWithName:[self className]]) == nil) {
- [self logWithFormat:
- @"ERROR: did not find exported SoClass '%@' in product %@!",
+ [self errorWithFormat:
+ @"did not find exported SoClass '%@' in product %@!",
[self className], self->product];
return;
}
SoSelectorInvocation *method;
if (_config == nil) {
- [self logWithFormat:
- @"ERROR: missing config for selector invocation method: '%@'",
- _name];
+ [self errorWithFormat:
+ @"missing config for selector invocation method: '%@'",
+ _name];
return nil;
}
selector = [config objectForKey:@"name"];
if ([selector length] == 0) {
- [self logWithFormat:
- @"ERROR: missing 'name' in selector config of method '%@': %@",
- _name, _config];
+ [self errorWithFormat:
+ @"missing 'name' in selector config of method '%@': %@",
+ _name, _config];
return nil;
}
[method setArgumentSpecifications:argspecs];
}
else {
- [self logWithFormat:@"ERROR: cannot handle selector configuration: %@",
- _config];
+ [self errorWithFormat:@"cannot handle selector configuration: %@",
+ _config];
return nil;
}
return method;
// TODO: should we allow/use SoClasses here?
if ((valueClass = NSClassFromString(valueClassName)) == Nil) {
- [self logWithFormat:
- @"ERROR: did not find value class '%@' for slot: '%@'",
- valueClassName, _name];
+ [self errorWithFormat:
+ @"did not find value class '%@' for slot: '%@'",
+ valueClassName, _name];
return NO;
}
}
value = [self instantiateObjectOfClass:valueClass withPlist:value];
if (value == nil) {
- [self logWithFormat:
- @"ERROR: could not initialize value of slot %@ with class %@",
+ [self errorWithFormat:
+ @"could not initialize value of slot %@ with class %@",
_name, valueClassName];
return NO;
}
value = [[[valueClass alloc] init] autorelease];
if (value == nil) {
- [self logWithFormat:
- @"ERROR: could not initialize value of slot '%@' with class: %@",
- _name, valueClassName];
+ [self errorWithFormat:
+ @"could not initialize value of slot '%@' with class: %@",
+ _name, valueClassName];
return NO;
}
}
return;
}
else {
- [self logWithFormat:
- @"WARNING: no product object for first name '%@' "
- @"(name=%@,bundle=%@)",
- firstProductName, productName, bundlePath];
+ [self warnWithFormat:
+ @"no product object for first name '%@' (name=%@,bundle=%@)",
+ firstProductName, productName, bundlePath];
}
}
while ((rqname = [requiredProducts nextObject])) {
if (![self loadProductNamed:rqname]) {
if ([rqname isEqualToString:@"MAIN"]) continue;
- [self logWithFormat:@"ERROR: failed to load product %@ required by %@.",
- rqname, _name];
+ [self errorWithFormat:@"failed to load product %@ required by %@.",
+ rqname, _name];
return NO;
}
}
type:[_frameworkName pathExtension]];
}
if (bundle == nil) {
- [self debugWithFormat:@"WARNING: missing bundle for framework: '%@'",
+ [self warnWithFormat:@"missing bundle for framework: '%@'",
_frameworkName];
goto fallback;
}
}
else {
if ((bundle = [self->product bundle]) == nil) {
- [self debugWithFormat:@"WARNING: missing bundle for product: %@",
- self->product];
+ [self warnWithFormat:@"missing bundle for product: %@", self->product];
goto fallback;
}
}
inFramework:[b bundlePath]
languages:languages];
if (p == nil) {
- [self logWithFormat:@"ERROR: did not find product resource: %@", _key];
+ [self errorWithFormat:@"did not find product resource: %@", _key];
return nil;
}
/* load data */
if ((data = [NSData dataWithContentsOfMappedFile:p]) == nil) {
- [self logWithFormat:@"ERROR: failed to load product resource: %@", _key];
+ [self errorWithFormat:@"failed to load product resource: %@", _key];
return nil;
}
[r setContent:data];
if ((ctype = [self mimeTypeForExtension:pe]) == nil) {
- [self logWithFormat:
- @"WARNING: did not recognize extension '%@', "
- @"delivering as application/octet-stream.", pe];
+ [self warnWithFormat:@"did not recognize extension '%@', "
+ @"delivering as application/octet-stream.", pe];
ctype = @"application/octet-stream";
}
self->sel = sel_register_name(sname);
#else
/* TODO: not tested against this ObjC runtime */
- NSLog(@"WARNING(%s): not tested against this ObjC runtime, "
- @"product bundle loading may be broken.", __PRETTY_FUNCTION__);
+ [self warnWithFormat:@"(%s): not tested against this ObjC runtime, "
+ @"product bundle loading may be broken.", __PRETTY_FUNCTION__];
#endif
}
if (self->sel == NULL)
- [self logWithFormat:@"WARNING: did not find selector: %@", _name];
+ [self warnWithFormat:@"did not find selector: %@", _name];
}
- (void)setDoesAddContextParameter:(BOOL)_flag {
// TODO: I guess that should be improved a bit in the dispatcher
if ((soapEnvelope = [_ctx valueForKey:@"SOAPEnvelope"]) == nil) {
// TODO: generate some kind of fault? (NSException?)
- [self logWithFormat:@"ERROR: no SOAP envelope available in context!"];
+ [self errorWithFormat:@"no SOAP envelope available in context!"];
return nil;
}
if ([_type isEqualToString:@"SOAP"])
return [self extractSOAPArgumentsFromContext:_ctx specification:_spec];
- [self logWithFormat:
- @"ERROR: cannot extract parameters for request type: '%@'", _type];
+ [self errorWithFormat:
+ @"cannot extract parameters for request type: '%@'", _type];
return nil;
}
selector = [self selectorForNumberOfArguments:[args count]];
if (selector == NULL) {
- [self logWithFormat:@"WARNING: missing selector for invocation!"];
+ [self warnWithFormat:@"missing selector for invocation!"];
return [self noSelectorForArgumentCountError:[args count]];
}
if ([self doesAddContextParameter]) callArgCount++;
if ((selector = [self selectorForNumberOfArguments:callArgCount]) == NULL) {
- [self logWithFormat:@"WARNING: missing selector for invocation (args=%d)!",
- callArgCount];
+ [self warnWithFormat:@"missing selector for invocation (args=%d)!",
+ callArgCount];
return [self noSelectorForArgumentCountError:callArgCount];
}
continue;
if ((bundle = [bm bundleWithPath:lPath]) == nil) {
- [self logWithFormat:@"WARNING: could not get bundle for path: '%@'",
- lPath];
+ [self warnWithFormat:@"could not get bundle for path: '%@'",
+ lPath];
continue;
}
if (![bundle load]) {
- [self logWithFormat:@"WARNING: could not load bundle: '%@'", lPath];
+ [self warnWithFormat:@"could not load bundle: '%@'", lPath];
continue;
}
- (void)initScriptWithComponent:(WOComponent *)_object {
#if 1
- [self logWithFormat:@"ERROR: cannot apply script on object: %@", _object];
+ [self errorWithFormat:@"cannot apply script on object: %@", _object];
#else
/* fixed on JavaScript, part should have a language ... */
NS_DURING {
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WODParser.m 1 2004-08-20 10:08:27Z znek $
#include "WODParser.h"
#include "common.h"
}
if ([_mappings objectForKey:elementName] != nil)
- NSLog(@"WARNING: duplicate definition of element %@ !", elementName);
+ [self warnWithFormat:@"duplicate definition of element %@ !",
+ elementName];
def = [self elementDefinitionForComponent:componentName
associations:entry
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WOHTMLParser.m 1 2004-08-20 10:08:27Z znek $
#include "WOHTMLParser.h"
#include <NGObjWeb/WODynamicElement.h>
if ((name = _parseStringValue(_zone, _buffer, _idx,_len,_exc,self)) == nil) {
#if HEAVY_DEBUG
- NSLog(@"ERROR: got no name for hash tag '<#NAME>'");
+ [self errorWithFormat:@"got no name for hash tag '<#NAME>'"];
#endif
if (_exc) // if there was an error ..
return nil;
attrs = _parseTagAttributes(_zone, _buffer, _idx, _len, _exception, self);
if (attrs == nil) {
- //NSLog(@"ERROR: got no attributes for WO tag (need at least 'NAME')..");
-
+ //[self errorWithFormat:
+ // @"got no attributes for WO tag (need at least 'NAME').."];
+
if (_exception) // if there was an error ..
return nil;
}
pos++;
}
if (pos >= _len) // EOF was reached
- break;
+ break;
}
else {
// skip '<', read usual tag
pos++;
if (pos >= _len) { // EOF was reached with opening '<'
- NSLog(@"WARNING: reached EOF with '<' at end !");
- break;
+ [self warnWithFormat:@"reached EOF with '<' at end !"];
+ break;
}
if (skipPlainTags) {
NSData *d;
if ((s = [[NSString alloc] initWithData:_data encoding:_from]) == nil) {
- [self logWithFormat:@"ERROR: template file has incorrect encoding!"];
+ [self errorWithFormat:@"template file has incorrect encoding!"];
return _data;
}
if ((d = [s dataUsingEncoding:_to]) == nil) {
- [self logWithFormat:
- @"ERROR: could not represent template file in parser encoding!"];
+ [self errorWithFormat:
+ @"could not represent template file in parser encoding!"];
return _data;
}
return d;
// TODO: move to an NSString category, isn't there a method for this in
// Foundation?!
if ((encoding = [self encodingForString:tmp]) == 0) {
- [self logWithFormat:
- @"ERROR(%s): cannot deal with template encoding: '%@'",
+ [self errorWithFormat:
+ @"(%s): cannot deal with template encoding: '%@'",
__PRETTY_FUNCTION__, tmp];
encoding = parserEncoding;
}
associations:nil
contentElements:_subElements];
if (element == nil) {
- [self logWithFormat:
- @"ERROR: could not instantiate child component reference."];
+ [self errorWithFormat:
+ @"could not instantiate child component reference."];
}
return element;
WODynamicElement *element;
if ((def = [self->definitions objectForKey:_element]) == nil) {
- [self logWithFormat:
- @"ERROR: did not find definition of dynamic element '%@'",
+ [self errorWithFormat:
+ @"did not find definition of dynamic element '%@'",
_element];
return [[NSClassFromString(@"WONoContentElement") alloc]
initWithElementName:_element
associations:assoc
contentElements:_subElements];
if (element == nil) {
- NSLog(@"ERROR: could not instantiate dynamic element of class %@",
- NSStringFromClass(elementClass));
+ [self errorWithFormat:@"could not instantiate dynamic element of class %@",
+ NSStringFromClass(elementClass)];
}
if ([assoc count] > 0) {
if (logExtraAssociations)
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WOxComponentElemBuilder.m 1 2004-08-20 10:08:27Z znek $
#include <NGObjWeb/WOxElemBuilder.h>
@implementation WOxComponentElemBuilder
-static BOOL debugOn = NO;
+static NGLogger *debugLogger = nil;
+ (void)initialize {
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
- debugOn =
- [[ud objectForKey:@"WOxComponentElemBuilderDebugEnabled"] boolValue];
+ NGLoggerManager *lm;
+ static BOOL didInit = NO;
+ if (didInit)
+ return;
+ didInit = YES;
+ lm = [NGLoggerManager defaultLoggerManager];
+ debugLogger = [lm loggerForDefaultKey:@"WOxComponentElemBuilderDebugEnabled"];
}
/* extracting associations */
if (LiveChildRefClass == Nil)
LiveChildRefClass = NSClassFromString(@"WOComponentReference");
- if (debugOn)
- [self debugWithFormat:@"build component-reference: %@",_element];
+ if (debugLogger)
+ [debugLogger debugWithFormat:@"build component-reference: %@", _element];
value = [_element attribute:@"value" namespaceURI:XMLNS_OD_BIND];
if ([value length] == 0) return nil;
/* build element */
- if (debugOn) {
- [self debugWithFormat:
- @" create reference for keypath: '%@': children=%@, assocs=%@",
- value, children, assocs];
+ if (debugLogger) {
+ [debugLogger debugWithFormat:
+ @"create reference for keypath: '%@': children=%@, "
+ @"assocs=%@",
+ value, children, assocs];
}
de = [[LiveChildRefClass alloc]
initWithName:[_b uniqueIDForNode:_element]
associations:assocs
contentElements:children];
- if (debugOn) [self debugWithFormat:@" built: %@", de];
+ if (debugLogger) [debugLogger debugWithFormat:@"built: %@", de];
return de;
}
NSString *compName;
if (![[_element namespaceURI] isEqualToString:XMLNS_OD_BIND]) {
- if (debugOn) {
+ if (debugLogger) {
[self debugWithFormat:
@"do not process element, not in bind namespace: %@", _element];
}
_element, _element];
}
- if (debugOn)
- [self debugWithFormat:@"creating static component reference: %@",_element];
-
+ if (debugLogger)
+ [debugLogger debugWithFormat:@"creating static component reference: %@",
+ _element];
+
if (ChildRefClass == Nil)
ChildRefClass = NSClassFromString(@"WOChildComponentReference");
cid = [_b uniqueIDForNode:_element];
- if (debugOn)
- [self debugWithFormat:@"BUILD Component(%@): %@", cid, _element];
+ if (debugLogger)
+ [debugLogger debugWithFormat:@"BUILD Component(%@): %@", cid, _element];
/* construct child elements */
bindings = [self associationsForAttributes:[_element attributes]
templateBuilder:_b];
- if (debugOn)
- [self debugWithFormat:@" using bindings: %@", bindings];
+ if (debugLogger)
+ [debugLogger debugWithFormat:@"using bindings: %@", bindings];
[_b registerSubComponentWithId:cid
componentName:compName
/* debugging */
- (BOOL)isDebuggingEnabled {
- return debugOn;
+ return debugLogger != nil;
}
@end /* WOxComponentElemBuilder */
@implementation WOxElemBuilder
-static Class StrClass = Nil;
-static Class AStrClass = Nil;
+static Class StrClass = Nil;
+static Class AStrClass = Nil;
static NSDictionary *defaultAssocMap = nil;
-static Class ValAssoc = Nil;
+static Class ValAssoc = Nil;
static BOOL logAssocMap = NO;
static BOOL logAssocCreation = NO;
static BOOL debugOn = NO;
+static NGLogger *logger = nil;
+ (int)version {
return 1;
}
+ (void)initialize {
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
+ NSUserDefaults *ud;
+ NGLoggerManager *lm;
static BOOL didInit = NO;
+
if (didInit) return;
didInit = YES;
-
+
+ ud = [NSUserDefaults standardUserDefaults];
+ lm = [NGLoggerManager defaultLoggerManager];
+
+ logger = [lm loggerForClass:self];
+ [logger setLogLevel:[WOApplication isDebuggingEnabled] ? NGLogLevelDebug
+ : NGLogLevelInfo];
+
StrClass = NSClassFromString(@"_WOSimpleStaticString");
if (StrClass == Nil)
- NSLog(@"ERROR: missing class _WOSimpleStaticString !");
+ [logger errorWithFormat:@"missing class _WOSimpleStaticString !"];
AStrClass = NSClassFromString(@"_WOSimpleStaticASCIIString");
if (AStrClass == Nil)
- NSLog(@"ERROR: missing class _WOSimpleStaticASCIIString !");
+ [logger errorWithFormat:@"missing class _WOSimpleStaticASCIIString !"];
logAssocMap = [ud boolForKey:@"WOxElemBuilder_LogAssociationMapping"];
logAssocCreation =
[ud boolForKey:@"WOxElemBuilder_LogAssociationCreation"];
- if (logAssocMap) NSLog(@"Note: association mapping is logged!");
- if (logAssocCreation) NSLog(@"Note: association creation is logged!");
-
+ if (logAssocMap)
+ [logger logWithFormat:@"association mapping is logged!"];
+ if (logAssocCreation)
+ [logger logWithFormat:@"association creation is logged!"];
+
defaultAssocMap = [[ud dictionaryForKey:@"WOxAssociationClassMapping"] copy];
if (defaultAssocMap == nil)
- NSLog(@"WARNING: WOxAssociationClassMapping default is not set!");
+ [logger warnWithFormat:
+ @"WOxAssociationClassMapping default is not set!"];
if (ValAssoc == Nil)
ValAssoc = NSClassFromString(@"WOValueAssociation");
}
+ (WOxElemBuilder *)createBuilderQueue:(NSArray *)_classNames {
- unsigned i, count;
+ unsigned i, count;
WOxElemBuilder *first, *current = nil;
NSMutableArray *missingBuilders = nil;
c = [self associationClassForNamespaceURI:[_attribute namespaceURI]];
if (c == Nil) {
- [self logWithFormat:
- @"WARNING, found no association class for "
- @"attribute %@ (namespace=%@)",
+ [self warnWithFormat:
+ @"found no association class for attribute %@ (namespace=%@)",
_attribute, [_attribute namespaceURI]];
return nil;
}
if (logAssocMap) {
[self logWithFormat:@"use class %@ for namespaceURI %@ (attribute %@)",
- c, [_attribute namespaceURI], [_attribute name]];
+ c, [_attribute namespaceURI], [_attribute name]];
}
assoc = [[c alloc] initWithString:value];
if (logAssocCreation) {
[self logWithFormat:@"created assoc %@ for attribute %@",
- assoc, [_attribute name]];
+ assoc, [_attribute name]];
}
return [assoc autorelease];
clazz = NSClassFromString(className);
if (clazz == Nil) {
- [self logWithFormat:@"WARNING: did not find association class: '%@'",
+ [self warnWithFormat:@"did not find association class: '%@'",
className];
continue;
}
/* logging */
++ (id)logger {
+ return logger;
+}
+- (id)logger {
+ return logger;
+}
+
- (void)logWithFormat:(NSString *)_format, ... {
NSString *value = nil;
va_list ap;
# include <NGExtensions/NGExtensions.h>
#define IS_DEPRECATED \
- NSLog(@"WARNING: used deprecated method: %s:%i.", \
- __PRETTY_FUNCTION__, __LINE__);
+ [self warnWithFormat:@"used deprecated method: %s:%i.", \
+ __PRETTY_FUNCTION__, __LINE__];
@interface NSException(NGObjWeb_Templates_setUserInfo)
- (id)setReason:(NSString *)_reason;
# version file
-SUBMINOR_VERSION:=90
+SUBMINOR_VERSION:=91
-# v4.5.84 required libNGExtensions v4.5.127
+# v4.5.91 requires libNGExtensions v4.5.134
+# v4.5.84 requires libNGExtensions v4.5.127
# v4.3.42 requires libNGExtensions v4.3.116
# v4.3.40 requires libNGExtensions v4.3.115
# v4.2.413 requires libSaxObjC v4.2.33
- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
if (![_ctx isInForm]) {
[[_ctx component]
- logWithFormat:@"WARNING: you must use %@ inside a form !",
+ warnWithFormat:@"you must use %@ inside a form !",
NSStringFromClass([self class])];
return;
}
#include <time.h>
@interface WOApplication(PrivateMethods)
++ (id)logger;
- (id)_loadComponentDefinitionWithName:(NSString *)_name
language:(NSArray *)_langs;
- (NSDictionary *)memoryStatistics;
c = [(id<NSObject>)clazz performSelector:@selector(defaultSNSConnection)];
if (c == nil) {
- [self logFatalWithFormat:@"could not connect SNS, exiting .."];
+ [[self logger] fatalWithFormat:@"could not connect SNS, exiting .."];
exit(20);
}
- [self logInfoWithFormat:@"SNS enabled"];
+ [[self logger] logWithFormat:@"SNS enabled"];
}
+ (void)_initializeWOApp {
if ([ud boolForKey:@"WOContactSNS"])
[self _setupSNS];
else
- [self logInfoWithFormat:@"SNS support disabled."];
+ [[self logger] logWithFormat:@"SNS support disabled."];
NSDateClass = [NSDate class];
WOTemplateClass = [WOTemplate class];
e = [keys objectEnumerator];
while((key = [e nextObject]) != nil) {
if ([key hasPrefix:@"WO"] || [key isEqualToString:@"NSProjectSearchPath"])
- [self logInfoWithFormat:@"[default]: %@ = %@",
+ [self logWithFormat:@"[default]: %@ = %@",
key,
[[ud objectForKey:key] description]];
}
- (void)processHupSignal:(int)_signal {
/* this isn't called immediatly */
- [self logInfoWithFormat:@"terminating on SIGHUP ..."];
+ [self logWithFormat:@"terminating on SIGHUP ..."];
[self terminate];
}
if (self->path == nil) {
if ((self->path = [[self _lookupAppPath] copy]) == nil) {
- [self logDebugWithFormat:@"could not find wrapper of application !"];
+ [self debugWithFormat:@"could not find wrapper of application !"];
missingPath = YES;
return nil;
}
NSDictionary *td;
if ((t = [NSThread currentThread]) == nil) {
- [self logErrorWithFormat:@"missing current thread !!!"];
+ [self errorWithFormat:@"missing current thread !!!"];
return nil;
}
if ((td = [t threadDictionary]) == nil) {
- [self logErrorWithFormat:
+ [self errorWithFormat:
@"missing current thread's dictionary (thread=%@) !!!",
t];
return nil;
- (WOSession *)createSessionForRequest:(WORequest *)_request {
if ([self respondsToSelector:@selector(createSession)]) {
/* call deprecated method */
- [self logWarnWithFormat:@"calling deprecated -createSession .."];
+ [self warnWithFormat:@"calling deprecated -createSession .."];
return [self createSession];
}
else {
if ([self respondsToSelector:@selector(restoreSession)]) {
/* call deprecated method */
- [self logWarnWithFormat:@"calling deprecated -restoreSession .."];
+ [self warnWithFormat:@"calling deprecated -restoreSession .."];
return [self restoreSession];
}
WOSessionStore *store;
if ((store = [self sessionStore]) == nil) {
- [self logErrorWithFormat:@"missing session store ..."];
+ [self errorWithFormat:@"missing session store ..."];
}
else {
session = [store restoreSessionWithID:_sid request:[_ctx request]];
if ([sid respondsToSelector:@selector(objectEnumerator)]) {
NSEnumerator *e;
- [self logErrorWithFormat:@"got multiple session IDs !"];
+ [self errorWithFormat:@"got multiple session IDs !"];
e = [sid objectEnumerator];
while ((_sid = [e nextObject])) {
if ((session = [self restoreSessionWithID:_sid inContext:_ctx]))
return session;
- //NSLog(@"WARNING: did not find session for sid %@", _sid);
+ //[self warnWithFormat:@"did not find session for sid %@", _sid);
}
}
}
if ([self respondsToSelector:@selector(saveSession:)]) {
/* call deprecated method */
- [self logWarnWithFormat:@"calling deprecated -saveSession: .."];
+ [self warnWithFormat:@"calling deprecated -saveSession: .."];
[self saveSession:[_ctx session]];
return;
}
if (perfLogger) {
NSTimeInterval rt;
rt = [[NSDateClass date] timeIntervalSince1970] - startSnSleep;
- [perfLogger logInfoWithFormat:@"[woapp]: session -sleep took %4.3fs.",
+ [perfLogger logWithFormat:@"[woapp]: session -sleep took %4.3fs.",
rt < 0.0 ? -1.0 : rt];
}
if (perfLogger) {
NSTimeInterval rt;
rt = [[NSDateClass date] timeIntervalSince1970] - startStore;
- [perfLogger logInfoWithFormat:@"[woapp]: storing sn in store took %4.3fs.",
+ [perfLogger logWithFormat:@"[woapp]: storing sn in store took %4.3fs.",
rt < 0.0 ? -1.0 : rt];
}
}
if (perfLogger) {
NSTimeInterval rt;
rt = [[NSDateClass date] timeIntervalSince1970] - startSave;
- [perfLogger logInfoWithFormat:@"[woapp]: saveSessionForContext took %4.3fs.",
+ [perfLogger logWithFormat:@"[woapp]: saveSessionForContext took %4.3fs.",
rt < 0.0 ? -1.0 : rt];
}
}
#endif
if ([self respondsToSelector:@selector(handleSessionCreationError)]) {
- [self logWarnWithFormat:@"called deprecated -handleSessionCreationError method"];
+ [self warnWithFormat:@"called deprecated -handleSessionCreationError method"];
return [self handleSessionCreationError];
}
- [self logErrorWithFormat:@"could not create session for context %@", _ctx];
+ [self errorWithFormat:@"could not create session for context %@", _ctx];
[response setStatus:200];
[response appendContentString:@"<h4>Session Creation Error</h4>\n<pre>"];
- (WOResponse *)handleSessionRestorationErrorInContext:(WOContext *)_ctx {
if ([self respondsToSelector:@selector(handleSessionRestorationError)]) {
- [self logWarnWithFormat:@"calling deprecated "
+ [self warnWithFormat:@"calling deprecated "
@"-handleSessionRestorationError method"];
return [self handleSessionRestorationError];
}
- [self logErrorWithFormat:@"could not restore session for context %@", _ctx];
+ [self errorWithFormat:@"could not restore session for context %@", _ctx];
return nil;
}
#if 0 && DEBUG
if ([(p = [self path]) length] > 0)
- [self logDebugWithFormat:@"setup WOResourceManager at path '%@' ...", p];
+ [self debugWithFormat:@"setup WOResourceManager at path '%@' ...", p];
#else
p = [self path];
#endif
Class dynamicElementClass = NSClassFromString(_name);
if (dynamicElementClass == Nil) {
- [self logWarnWithFormat:@"did not find dynamic element class %@ !", _name];
+ [self warnWithFormat:@"did not find dynamic element class %@ !", _name];
return nil;
}
if (![dynamicElementClass isDynamicElement]) {
- [self logWarnWithFormat:@"class %@ is not a dynamic element class !", _name];
+ [self warnWithFormat:@"class %@ is not a dynamic element class !", _name];
return nil;
}
[[start objectForKey:@"VmSize"] intValue];
lib = [[stop objectForKey:@"VmLib"] intValue] -
[[start objectForKey:@"VmLib"] intValue];
- [self logDebugWithFormat:@"loaded component %@; rss=%i vm=%i lib=%i.",
- _name, rss,vmsize,lib];
+ [self debugWithFormat:@"loaded component %@; rss=%i vm=%i lib=%i.",
+ _name, rss,vmsize,lib];
}
#endif
}
- (WOResponse *)handlePageRestorationErrorInContext:(WOContext *)_ctx {
- [self logErrorWithFormat:
+ [self errorWithFormat:
@"could not restore page for context-id %@\n in context %@",
[_ctx currentElementID], _ctx];
WOResponse *r = nil;
if ([self respondsToSelector:@selector(handleException:)]) {
- [self logWarnWithFormat:@"calling deprecated -handleException method !"];
+ [self warnWithFormat:@"calling deprecated -handleException method !"];
return [self handleException:_exc];
}
? 1 : 0;
}
if (doCore) {
- [self logFatalWithFormat:@"%@: caught (ctx=%@):\n %@.",
- self, _ctx, _exc];
+ [self fatalWithFormat:@"%@: caught (ctx=%@):\n %@.",
+ self, _ctx, _exc];
abort();
}
}
#endif
if (_ctx == nil) {
- [self logFatalWithFormat:@"%@: caught (without context):\n %@.",
- self, _exc];
+ [self fatalWithFormat:@"%@: caught (without context):\n %@.",
+ self, _exc];
[self terminate];
}
else if (rq == nil) {
- [self logFatalWithFormat:@"%@: caught (without request):\n %@.",
- self, _exc];
+ [self fatalWithFormat:@"%@: caught (without request):\n %@.",
+ self, _exc];
[self terminate];
}
else {
NSString *str = nil;
NSString *bt = nil;
- [self logErrorWithFormat:@"%@: caught:\n %@\nin context:\n %@.",
+ [self errorWithFormat:@"%@: caught:\n %@\nin context:\n %@.",
self, _exc, _ctx];
#if LIB_FOUNDATION_LIBRARY
#endif
if ((r = [WOResponse responseWithRequest:rq]) == nil)
- [self logErrorWithFormat:@"could not create response !"];
+ [self errorWithFormat:@"could not create response !"];
[r setHeader:@"text/html" forKey:@"content-type"];
[r setHeader:@"no-cache" forKey:@"cache-control"];
#if !LIB_FOUNDATION_LIBRARY
- (id)valueForUndefinedKey:(NSString *)_key {
- [self logWarnWithFormat:@"tried to access undefined KVC key: '%@'",
+ [self warnWithFormat:@"tried to access undefined KVC key: '%@'",
_key];
return nil;
}
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WOChildComponentReference.m 1 2004-08-20 10:08:27Z znek $
#include "WOChildComponentReference.h"
#include "WOComponent+private.h"
NSTimeInterval st = 0.0;
if ((parent = [_ctx component]) == nil) {
- [self logWithFormat:
- @"WARNING(%s): did not find parent component of child %@",
+ [self warnWithFormat:
+ @"%s: did not find parent component of child %@",
__PRETTY_FUNCTION__, self->childName];
return;
}
if ((child = [parent childComponentWithName:self->childName]) == nil) {
- [self logWithFormat:
- @"WARNING: did not find child component %@ of parent %@",
+ [self warnWithFormat:
+ @"did not find child component %@ of parent %@",
self->childName, [parent name]];
return;
}
if ((parent = [_ctx component]) == nil) {
[[_ctx session]
- logWithFormat:@"WARNING: did not find parent component of child %@",
+ warnWithFormat:@"did not find parent component of child %@",
self->childName];
return nil;
}
if ((child = [parent childComponentWithName:self->childName]) == nil) {
[[_ctx session]
- logWithFormat:
- @"WARNING: did not find child component %@ of parent %@",
+ warnWithFormat:
+ @"did not find child component %@ of parent %@",
self->childName, [parent name]];
return nil;
}
NSTimeInterval st = 0.0;
if ((parent = [_ctx component]) == nil) {
- [self logWithFormat:
- @"WARNING(%s): did not find parent component of child %@",
+ [self warnWithFormat:
+ @"%s: did not find parent component of child %@",
__PRETTY_FUNCTION__, self->childName];
return;
}
if ((child = [parent childComponentWithName:self->childName]) == nil) {
- [self logWithFormat:
- @"WARNING: did not find child component %@ of parent %@",
+ [self warnWithFormat:
+ @"did not find child component %@ of parent %@",
self->childName, [parent name]];
[_response appendContentString:@"<pre>[missing component: "];
[_response appendContentHTMLString:self->childName];
static Class NSDateClass = Nil;
static Class WOComponentClass = Nil;
-static BOOL profElements = NO;
+
+static NGLogger *perfLogger = nil;
+
static BOOL debugOn = NO;
static BOOL debugComponentAwake = NO;
static BOOL debugTemplates = NO;
return [super version] + 0 /* v2 */;
}
+ (void)initialize {
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
+ NSUserDefaults *ud;
+ NGLoggerManager *lm;
static BOOL didInit = NO;
+
if (didInit) return;
didInit = YES;
NSAssert2([super version] == 2,
@"invalid superclass (%@) version %i !",
NSStringFromClass([self superclass]), [super version]);
-
- WOComponentClass = [WOComponent class];
- NSDateClass = [NSDate class];
-
- profElements = [ud boolForKey:@"WOProfileElements"];
+
+ ud = [NSUserDefaults standardUserDefaults];
+ lm = [NGLoggerManager defaultLoggerManager];
+
+ WOComponentClass = [WOComponent class];
+ NSDateClass = [NSDate class];
+ perfLogger = [lm loggerForDefaultKey:@"WOProfileElements"];
debugOn = [WOApplication isDebuggingEnabled];
debugComponentAwake = [ud boolForKey:@"WODebugComponentAwake"];
abortOnAwakeComponentInCtxDealloc =
if (self->context)
[self ensureAwakeInContext:self->context];
else {
- [self logWithFormat:
- @"WARNING: no context given to -initWithContext: ..."];
+ [self warnWithFormat:
+ @"no context given to -initWithContext: ..."];
}
}
return self;
#endif
if (self->componentFlags.isAwake) {
- [self logWithFormat:
- @"WARNING: session will dealloc, "
- @"but component 0x%08X is awake (ctx=%@) !", self, self->context];
+ [self warnWithFormat:
+ @"session will dealloc, but component 0x%08X is awake (ctx=%@) !",
+ self, self->context];
[self _sleepWithContext:self->context];
}
the event?!
*/
[self debugWithFormat:
- @"WARNING: context %@ will dealloc, "
- @"but component is awake in ctx %@!",
+ @"context %@ will dealloc, but component is awake in ctx %@!",
[_notification object], [self->context contextID]];
if (abortOnAwakeComponentInCtxDealloc)
abort();
- (void)sleep {
if (debugOn) {
if (self->componentFlags.isAwake) {
- [self debugWithFormat:
- @"WARNING: component should not be awake if sleep is called !"];
+ [self warnWithFormat:
+ @"component should not be awake if sleep is called !"];
}
if (self->context == nil) {
- [self debugWithFormat:
- @"WARNING: context should not be nil if sleep is called !"];
+ [self warnWithFormat:
+ @"context should not be nil if sleep is called !"];
}
}
#endif
if (debugComponentAwake)
- [self logWithFormat:@"0x%08X ensureAwakeInContext:0x%08X", self, _ctx];
+ [self debugWithFormat:@"0x%08X ensureAwakeInContext:0x%08X", self, _ctx];
if (self->context == nil) [self _setContext:_ctx];
if (self->application == nil) self->application = [_ctx application];
}
- (void)_sleepWithContext:(WOContext *)_ctx {
if (debugComponentAwake)
- [self logWithFormat:@"0x%08X _sleepWithContext:0x%08X", self, _ctx];
+ [self debugWithFormat:@"0x%08X _sleepWithContext:0x%08X", self, _ctx];
if (_ctx != self->context) {
if ((self->context != nil) && (_ctx != nil)) {
/* component is active in different context ... */
- [self debugWithFormat:
- @"WARNING: sleep context mismatch (own=0x%08X vs given=0x%08X)",
+ [self warnWithFormat:
+ @"sleep context mismatch (own=0x%08X vs given=0x%08X)",
self->context, _ctx];
return;
}
- (WOSession *)session {
if (self->session == nil) {
if ((self->session = [[self context] session]) == nil) {
- [self logWithFormat:@"could not get session object from context %@",
+ [self debugWithFormat:@"could not get session object from context %@",
self->context];
}
}
if (self->session == nil)
- [self logWithFormat:@"WARNING: missing session for component!"];
+ [self warnWithFormat:@"missing session for component!"];
return self->session;
}
if (self->context)
return self->context;
- [self debugWithFormat:
- @"WARNING: missing context in component 0x%08X (component%s)",
+ [self warnWithFormat:
+ @"missing context in component 0x%08X (component%s)",
self,
self->componentFlags.isAwake ? " is awake" : " is not awake"];
if (abortOnMissingCtx) {
- [self logWithFormat:@"aborting, because ctx is missing !"];
+ [self errorWithFormat:@"aborting, because ctx is missing !"];
abort();
}
[self _setContext:[self->application context]];
if (self->context == nil)
- [self logWithFormat:@"WARNING: could not determine context object!"];
+ [self warnWithFormat:@"could not determine context object!"];
return self->context;
}
- (void)setName:(NSString *)_name {
if (![_name isNotNull])
- [self logWithFormat:@"WARNING: setting 'nil' name on component!"];
+ [self warnWithFormat:@"setting 'nil' name on component!"];
ASSIGNCOPY(self->wocName, _name);
}
if (_ext) _name = [_name stringByAppendingPathExtension:_ext];
if (cpath == nil) {
- NSLog(@"WARNING: no path set in component %@", [self name]);
+ [self warnWithFormat:@"no path set in component %@", [self name]];
return nil;
}
if (![fm fileExistsAtPath:cpath isDirectory:&isDirectory]) {
- NSLog(@"WARNING: component directory %@ does not exist !", cpath);
+ [self warnWithFormat:@"component directory %@ does not exist !", cpath];
return nil;
}
if (!isDirectory) {
- NSLog(@"WARNING: component path %@ is not a directory !", cpath);
+ [self warnWithFormat:@"component path %@ is not a directory !", cpath];
return nil;
}
WOElement *tmpl;
if ((resourceManager = [self resourceManager]) == nil) {
- [self logWithFormat:@"ERROR(%s): could not determine resource manager !",
- __PRETTY_FUNCTION__];
+ [self errorWithFormat:@"%s: could not determine resource manager !",
+ __PRETTY_FUNCTION__];
return nil;
}
: [[[self context] request] browserLanguages];
tmpl = [resourceManager templateWithName:_name languages:languages];
- if (debugTemplates) [self logWithFormat:@"found template: %@", tmpl];
+ if (debugTemplates) [self debugWithFormat:@"found template: %@", tmpl];
return tmpl;
}
child = [child resolveWithParent:self];
if (child == nil) {
- [self logWithFormat:@"Could not resolve component fault: %@", _name];
+ [self warnWithFormat:@"Could not resolve component fault: %@", _name];
return nil;
}
if (parent == nil) {
parent = [self parent];
- NSLog(@"WARNING: tried to set value of binding '%@' in component '%@' "
- @"without parent component (parent is '%@') !",
- _name, [self name], [parent name]);
+ [self warnWithFormat:@"tried to set value of binding '%@' in component "
+ @"'%@' without parent component (parent is '%@') !",
+ _name, [self name], [parent name]];
}
[[self retain] autorelease];
if (parent == nil) {
parent = [self parent];
- NSLog(@"WARNING: tried to retrieve value of binding '%@' in"
- @" component '%@' without parent component (parent is '%@') !",
- _name, [self name], [parent name]);
+ [self warnWithFormat:@"tried to retrieve value of binding '%@' in"
+ @" component '%@' without parent component (parent is '%@') !",
+ _name, [self name], [parent name]];
}
[[self retain] autorelease];
NSAssert(parent != self, @"parent component equals current component");
if (![parent respondsToSelector:action]) {
- [self logWithFormat:@"parent %@ doesn't respond to %@",
- [parent name], _name];
+ [self debugWithFormat:@"parent %@ doesn't respond to %@",
+ [parent name], _name];
return nil;
}
@"component %@ is not awake !", self);
if (debugOn) {
if (self->context != _ctx) {
- [self debugWithFormat:@"WARNING(%s): component ctx != ctx (%@ vs %@)",
+ [self debugWithFormat:@"%s: component ctx != ctx (%@ vs %@)",
__PRETTY_FUNCTION__, self->context, _ctx];
}
}
return;
}
- if (profElements)
+ if (perfLogger)
st = [[NSDateClass date] timeIntervalSince1970];
if (template->appendResponse) {
else
[template appendToResponse:_response inContext:_ctx];
- if (profElements) {
+ if (perfLogger) {
NSTimeInterval diff;
int i;
diff = [[NSDateClass date] timeIntervalSince1970] - st;
for (i = [_ctx componentStackCount]; i >= 0; i--)
printf(" ");
#endif
- printf("Template %s (comp %s): %0.3fs\n",
- [[_ctx elementID] cString],
- [[self name] cString],
- diff);
+ [perfLogger logWithFormat:@"Template %@ (comp %@): %0.3fs\n",
+ [_ctx elementID],
+ [self name],
+ diff];
}
}
response = [WOResponse responseWithRequest:[ctx request]];
if (ctxID == nil) {
- [self logWithFormat:@"missing ctx-id for context %@", ctx];
+ [self debugWithFormat:@"missing ctx-id for context %@", ctx];
ctxID = @"noctx";
}
if ([self logComponentVariableCreations]) {
/* only if we have a subclass, we can store values in ivars ... */
if (![[self->wocVariables objectForKey:_key] isNotNull]) {
- [self logWithFormat:@"Created component variable (class=%@): '%@'.",
+ [self debugWithFormat:
+ @"Created component variable (class=%@): '%@'.",
NSStringFromClass(self->isa), _key];
}
}
return;
}
- [self logWithFormat:
+ [self debugWithFormat:
@"value %@ could not set via method or KVC "
@"(self responds to %@: %s).",
- _key, _key,
+ _key, _key,
[self respondsToSelector:NSSelectorFromString(_key)] ? "yes" : "no"];
#if 0
return NO;
return value;
#if DEBUG && 0
- [self logWithFormat:@"KVC: accessed the component variable %@", _key];
+ [self debugWithFormat:@"KVC: accessed the component variable %@", _key];
#endif
if ((value = [self objectForKey:_key]))
return value;
if ([self logComponentVariableCreations]) {
/* only if we have a subclass, we can store values in ivars ... */
if (![[self->wocVariables objectForKey:_key] isNotNull]) {
- [self logWithFormat:@"Created component variable (class=%@): '%@'.",
- NSStringFromClass(self->isa), _key];
+ [self debugWithFormat:@"Created component variable (class=%@): '%@'.",
+ NSStringFromClass(self->isa), _key];
}
}
#endif
- (id)valueForUndefinedKey:(NSString *)_key {
// Note: this is not used on libFoundation, insufficient KVC implementation
#if DEBUG && 0
- [self logWithFormat:@"KVC: accessed the component variable %@", _key];
+ [self debugWithFormat:@"KVC: accessed the component variable %@", _key];
#endif
return [self objectForKey:_key];
}
- (void)unableToSetNilForKey:(NSString *)_key {
// TODO: should we call setValue:NSNull forKey?
- [self logWithFormat:@"ERROR: unable to set 'nil' for key: '%@'", _key];
+ [self errorWithFormat:@"unable to set 'nil' for key: '%@'", _key];
}
#endif /* KVC */
- (void)validationFailedWithException:(NSException *)_exception
value:(id)_value keyPath:(NSString *)_keyPath
{
- [self logWithFormat:
- @"WARNING: formatter failed for value %@ (keyPath=%@): %@",
+ [self warnWithFormat:
+ @"formatter failed for value %@ (keyPath=%@): %@",
_value, _keyPath, [_exception reason]];
}
[child release];
}
else {
- [self logWithFormat:
- @"ERROR(%s): "
- @"Could not instantiate child fault %@, component: '%@'",
+ [self errorWithFormat:
+ @"(%s): Could not instantiate child fault %@, component: '%@'",
__PRETTY_FUNCTION__, key, [childInfo componentName]];
}
}
}
- (id)init {
- [self debugWithFormat:@"ERROR: called -init on WOComponentDefinition!"];
+ [self errorWithFormat:@"called -init on WOComponentDefinition!"];
[self release];
return nil;
}
static Class WOElementClass = Nil;
if (WOElementClass == Nil) WOElementClass = [WOElement class];
if (![cClass isKindOfClass:WOElementClass] && cClass != nil) {
- [self logWithFormat:@"WARNING(%s:%i): "
- @"component class %@ is not a subclass of WOElement !",
- __PRETTY_FUNCTION__, __LINE__,
- NSStringFromClass(cClass)];
+ [self warnWithFormat:@"(%s:%i): "
+ @"component class %@ is not a subclass of WOElement !",
+ __PRETTY_FUNCTION__, __LINE__,
+ NSStringFromClass(cClass)];
return NO;
}
}
}
- (BOOL)_checkComponentValidity:(id)component class:(Class)cClass {
if (![component isKindOfClass:cClass] && component != nil) {
- NSLog(@"WARNING2(%s:%i): component %@ is not a subclass of "
- @"component class %@ !",
- __PRETTY_FUNCTION__, __LINE__,
- component, NSStringFromClass(cClass));
+ [self warnWithFormat:@"(%s:%i): component %@ is not a subclass of "
+ @"component class %@ !",
+ __PRETTY_FUNCTION__, __LINE__,
+ component, NSStringFromClass(cClass)];
return NO;
}
return YES;
return;
if ((woo = [NSDictionary dictionaryWithContentsOfFile:wooPath]) == nil) {
- [self logWithFormat:@"ERROR: could not load .woo-file: '%@'", wooPath];
+ [self errorWithFormat:@"could not load .woo-file: '%@'", wooPath];
return;
}
if (debugOn) {
if (![component isKindOfClass:cClass]) {
- [self debugWithFormat:
- @"WARNING(%s:%i): component '%@' is not a subclass of "
- @"component class '%@' !",
- __PRETTY_FUNCTION__, __LINE__,
- component, NSStringFromClass(cClass)];
+ [self warnWithFormat:
+ @"(%s:%i): component '%@' is not a subclass of "
+ @"component class '%@' !",
+ __PRETTY_FUNCTION__, __LINE__,
+ component, NSStringFromClass(cClass)];
}
}
return component;
#endif
}
else if (response == nil) {
- [[WOApplication application]
- logWithFormat:
- @"WARNING: got no session restoration error, "
- @"but missing session !"];
+ [[WOApplication application] warnWithFormat:
+ @"got no session restoration error, "
+ @"but missing session !"];
}
}
else {
#endif
}
else {
- NSLog(@"WARNING(%s): did not enter request/response transaction ...",
- __PRETTY_FUNCTION__);
+ [self warnWithFormat:@"%s: did not enter request/response transaction ...",
+ __PRETTY_FUNCTION__];
}
/* tear down */
}
if ([serverURL length] == 0) {
- [self logWithFormat:
- @"ERROR: could not find x-webobjects-server-url header !"];
+ [self errorWithFormat:@"could not find x-webobjects-server-url header !"];
return nil;
}
if ([_path hasPrefix:@"/"]) {
#if DEBUG
- [self logWithFormat:@"WARNING: got absolute path '%@'", _path];
+ [self warnWithFormat:@"got absolute path '%@'", _path];
#endif
_path = [_path substringFromIndex:1];
}
#if DEBUG
if ([url length] == 0) {
- NSLog(@"WARNING(%s): could not determine session URL prefix !",
- __PRETTY_FUNCTION__);
+ [self warnWithFormat:@"(%s): could not determine session URL prefix !",
+ __PRETTY_FUNCTION__];
}
#endif
}
#if DEBUG
else {
- [self debugWithFormat:@"WARNING: -popCursor called without cycle ctx !"];
+ [self warnWithFormat:@"-popCursor called without cycle ctx !"];
}
#endif
}
if ([bp length] == 0) {
- [self logDebugWithFormat:@"%s: did not find the bundle '%@' "
- @"in search list %@",
- __PRETTY_FUNCTION__, _bundleName, chkPathes];
+ [self debugWithFormat:
+ @"%s: did not find the bundle '%@' in search list %@",
+ __PRETTY_FUNCTION__, _bundleName, chkPathes];
return 1;
}
if ((bundle = [NGBundle bundleWithPath:bp]) == nil) {
- [self logDebugWithFormat:@"%s: did not find %@ at %@ ...",
- __PRETTY_FUNCTION__, _bundleName, bp];
+ [self debugWithFormat:@"%s: did not find %@ at %@ ...",
+ __PRETTY_FUNCTION__, _bundleName, bp];
//return 1;
}
if (![bundle load]) {
- [self logErrorWithFormat:@"%s: could not load %@ %@ (path=%@)...",
+ [self errorWithFormat:@"%s: could not load %@ %@ (path=%@)...",
__PRETTY_FUNCTION__, _bundleName, bundle, bp];
//return 2;
}
//return 3;
}
- [self logDebugWithFormat:@"hosting bundle: %@", [bundle bundleName]];
+ [self debugWithFormat:@"hosting bundle: %@", [bundle bundleName]];
return 0;
}
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 {
- static id sharedLogger = nil;
- if(sharedLogger == nil) {
- sharedLogger = [[NGLogger alloc] initWithLogLevel:NGLogLevelDebug];
- }
- return sharedLogger;
+ return logger;
}
- (id)logger {
- return [[self class] logger];
+ 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;
}
#if !LIB_FOUNDATION_LIBRARY
- (void)setValue:(id)_value forUndefinedKey:(NSString *)_key {
- [self logWithFormat:
- @"WARNING: tried to set value for undefined KVC key: '%@'", _key];
+ [self warnWithFormat:
+ @"tried to set value for undefined KVC key: '%@'", _key];
}
- (id)valueForUndefinedKey:(NSString *)_key {
- [self logWithFormat:
- @"WARNING: tried to access undefined KVC key: '%@'", _key];
+ [self warnWithFormat:
+ @"tried to access undefined KVC key: '%@'", _key];
return nil;
}
actionName = @"default";
if ((*(&actionClass) = NSClassFromString(actionClassName)) == Nil) {
- [self logWithFormat:@"ERROR: did not find direct action class %@",
+ [self errorWithFormat:@"did not find direct action class %@",
actionClassName];
actionClass = [WODirectAction class];
}
application:app];
if (actionObject == nil) {
- [self logWithFormat:
- @"ERROR: could not create direct action object of class %@",
+ [self errorWithFormat:
+ @"could not create direct action object of class %@",
actionClassName];
actionObject = nil;
}
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WODisplayGroup.m 1 2004-08-20 10:08:27Z znek $
#include <NGObjWeb/WODisplayGroup.h>
#import <EOControl/EOControl.h>
return nil;
}
- (id)displayBatchContainingSelectedObject {
- NSLog(@"WARNING: %s not implemenented", __PRETTY_FUNCTION__);
+ [self warnWithFormat:@"%s not implemenented", __PRETTY_FUNCTION__];
[self updateDisplayedObjects];
return nil;
}
}
- (void)setSelectedObject:(id)_obj {
- NSLog(@"WARNING: %s not implemented.", __PRETTY_FUNCTION__);
+ [self warnWithFormat:@"%s not implemented.", __PRETTY_FUNCTION__];
}
- (id)selectedObject {
return nil;
- (void)setSelectedObjects:(NSArray *)_objs {
[self selectObjectsIdenticalTo:_objs];
- // NSLog(@"WARNING: %s not implemented.", __PRETTY_FUNCTION__);
+ // [self warnWithFormat:@"%s not implemented.", __PRETTY_FUNCTION__];
}
- (NSArray *)selectedObjects {
NSMutableArray *result;
return;
if (self->extraAttributes) {
- NSLog(@"ERROR(%s): tried to reset extra attributes (access denied) !!!",
- __PRETTY_FUNCTION__);
+ [self errorWithFormat:
+ @"(%s): tried to reset extra attributes (access denied) !!!",
+ __PRETTY_FUNCTION__];
return;
}
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WOElementID.m 1 2004-08-20 10:08:27Z znek $
#include "WOElementID.h"
#include "common.h"
return nil;
}
if (self->elementIdCount > NGObjWeb_MAX_ELEMENT_ID_COUNT) {
- [self logWithFormat:@"ERROR: request element ID is too long (%i parts)",
+ [self errorWithFormat:@"request element ID is too long (%i parts)",
self->elementIdCount];
[self release];
return nil;
id v;
if (self->elementIdCount < 1) {
- [self logWithFormat:
- @"WARNING: tried to increment a non-existing element-id"];
+ [self warnWithFormat:@"tried to increment a non-existing element-id"];
return;
}
else if (self->elementIdCount >= NGObjWeb_MAX_ELEMENT_ID_COUNT) {
- [self logWithFormat:
- @"ERROR: exceeded element-id restriction (max=%i)",
- NGObjWeb_MAX_ELEMENT_ID_COUNT];
+ [self errorWithFormat:@"exceeded element-id restriction (max=%i)",
+ NGObjWeb_MAX_ELEMENT_ID_COUNT];
return;
}
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WOFileSessionStore.m 1 2004-08-20 10:08:27Z znek $
#include <NGObjWeb/WOSessionStore.h>
return nil;
if (![_sid isKindOfClass:[NSString class]]) {
- NSLog(@"WARNING(%s): got invalid session id (expected string !): %@",
- __PRETTY_FUNCTION__, _sid);
+ [self warnWithFormat:@"%s: got invalid session id (expected string !): %@",
+ __PRETTY_FUNCTION__, _sid];
return nil;
}
@implementation WOHttpAdaptor
+static NGLogger *logger = nil;
static NGLogger *perfLogger = nil;
static BOOL WOHttpAdaptor_LogStream = NO;
static BOOL WOContactSNS = NO;
return [super version] + 1 /* v2 */;
}
+ (void)initialize {
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
- NGLoggerManager *um = [NGLoggerManager defaultLoggerManager];
+ NSUserDefaults *ud;
+ NGLoggerManager *lm;
static BOOL didInit = NO;
if (didInit) return;
didInit = YES;
-
+
NSAssert2([super version] == 1,
@"invalid superclass (%@) version %i !",
NSStringFromClass([self superclass]), [super version]);
+
+ ud = [NSUserDefaults standardUserDefaults];
+ lm = [NGLoggerManager defaultLoggerManager];
+ logger = [lm loggerForClass:self];
+ perfLogger = [lm loggerForDefaultKey:@"WOProfileHttpAdaptor"];
+
WOHttpAdaptor_LogStream = [ud boolForKey:@"WOHttpAdaptor_LogStream"];
- perfLogger = [um loggerForDefaultKey:@"WOProfileHttpAdaptor"];
// TODO: those two should be queried on demand to allow different defaults
WOPort = [[ud stringForKey:@"WOPort"] copy];
}
if (WOCoreOnHTTPAdaptorException)
- [self logWarnWithFormat:@"will dump core on HTTP adaptor exception!"];
+ [logger warnWithFormat:@"will dump core on HTTP adaptor exception!"];
}
- (id)autoBindAddress {
self->address = [self->address retain];
if (self->address == nil) {
- [_application logErrorWithFormat:
+ [_application errorWithFormat:
@"got no address for HTTP server (using arg '%@')", arg];
[self release];
return nil;
}
if (!WOContactSNS) {
- [_application logInfoWithFormat:@"%@ listening on address %@",
+ [_application logWithFormat:@"%@ listening on address %@",
NSStringFromClass([self class]),
[(id)self->address stringValue]];
}
/* events */
- (void)handleSIGPIPE:(int)_signal {
- [self logWarnWithFormat:@"caught SIGPIPE !"];
+ [self warnWithFormat:@"caught SIGPIPE !"];
}
- (void)registerForEvents {
self->address = [[self->socket localAddress] retain];
- [self logInfoWithFormat:@"bound to kernel assigned address %@: %@",
+ [self logWithFormat:@"bound to kernel assigned address %@: %@",
self->address, self->socket];
}
}
return self->maxThreadCount;
}
-/* logging */
-
-- (id)logger {
- static id sharedLogger = nil;
- if(sharedLogger == nil) {
- sharedLogger = [[NGLogger alloc] initWithLogLevel:NGLogLevelDebug];
- }
- return sharedLogger;
-}
-
/* run-loop */
- (void)_serverCatched:(NSException *)_exc {
- [self logErrorWithFormat:@"http server caught: %@", _exc];
+ [self errorWithFormat:@"http server caught: %@", _exc];
if (WOCoreOnHTTPAdaptorException) abort();
}
WOHttpTransaction *tx;
if (_socket == nil) {
- [self logErrorWithFormat:@"got no socket for transaction ??"];
+ [self errorWithFormat:@"got no socket for transaction ??"];
return NO;
}
if (perfLogger) {
t = [[NSDate date] timeIntervalSince1970] - t;
- [perfLogger logInfoWithFormat:@"handling of request took %4.3fs.",
- t < 0.0 ? -1.0 : t];
+ [perfLogger logWithFormat:@"handling of request took %4.3fs.",
+ t < 0.0 ? -1.0 : t];
}
}
id<NGSocketAddress> remote;
if ((remote = [_connection remoteAddress]) == nil) {
- [self logErrorWithFormat:
- @"missing remote address for connection: %@",
+ [self errorWithFormat:@"missing remote address for connection: %@",
_connection];
return nil;
}
return _connection;
}
- [self logErrorWithFormat:@"ACCESS DENIED: %@", ipAddr];
+ [self errorWithFormat:@"ACCESS DENIED: %@", ipAddr];
_connection = nil;
}
if (connection == nil)
[self _serverCatched:[self->socket lastException]];
else
- [self debugWithFormat:@"accepted connection: %@", connection];
+ [self debugWithFormat:@"accepted connection: %@", connection];
}
NS_HANDLER {
connection = nil;
[NSThread detachNewThreadSelector:@selector(_handleAcceptedConnection:)
toTarget:self
withObject:[connection retain]];
- [self logInfoWithFormat:@"detached new thread for request."];
+ [self logWithFormat:@"detached new thread for request."];
//[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:10]];
}
connection = nil;
[self->socket close];
[self->socket release]; self->socket = nil;
}
- [self logInfoWithFormat:@"adaptor stops application: %@ ...",
- self->application];
+ [self logWithFormat:@"adaptor stops application: %@ ...",
+ self->application];
exit(0);
}
}
@"WOAsyncResponseReadyNotification";
NSString *WOAsyncResponse = @"WOAsyncResponse";
-static int HTTP_PERFLOG = -1;
@interface WOCoreApplication(SimpleParserSelection)
static NSMutableDictionary *pendingTransactions = nil; // THREAD
static BOOL useSimpleParser = YES;
-static int debugOn = -1;
static int doCore = -1;
-static NSString *adLogPath = nil;
+static NSString *adLogPath = nil;
+static NGLogger *debugLogger = nil;
+static NGLogger *perfLogger = nil;
+ (int)version {
return 2;
}
+ (void)initialize {
+ NSUserDefaults *ud;
+ NGLoggerManager *lm;
static BOOL didInit = NO;
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
+
if (didInit) return;
didInit = YES;
-
+
+ lm = [NGLoggerManager defaultLoggerManager];
+ perfLogger = [lm loggerForDefaultKey:@"WOProfileHttpAdaptor"];
+ debugLogger = [lm loggerForDefaultKey:@"WODebugHttpTransaction"];
+
+ ud = [NSUserDefaults standardUserDefaults];
useSimpleParser = [ud boolForKey:@"WOHttpTransactionUseSimpleParser"];
- debugOn = [[ud objectForKey:@"WODebugHttpTransaction"] boolValue] ? 1 : 0;
doCore = [[ud objectForKey:@"WOCoreOnHTTPAdaptorException"] boolValue]?1:0;
adLogPath = [[ud stringForKey:@"WOAdaptorLogPath"] copy];
return [WOHttpAdaptor optionLogStream];
}
- (BOOL)optionLogPerf {
- return HTTP_PERFLOG;
+ return perfLogger ? YES : NO;
}
- (BOOL)isDebuggingEnabled {
- return debugOn ? YES : NO;
+ return debugLogger ? YES : NO;
}
- (id)initWithSocket:(id<NGActiveSocket>)_socket
application:(WOCoreApplication *)_app
{
- if (HTTP_PERFLOG == -1)
- HTTP_PERFLOG = [WOHttpAdaptor optionLogPerf] ? 1 : 0;
-
NSAssert(_socket, @"missing socket ...");
NSAssert(_app, @"missing application ...");
self->socket = [_socket retain];
- (void)reset {
if (self->asyncResponseToken) {
- [self logWithFormat:
- @"WARNING: resetting while async response pending ... (%@)",
+ [self warnWithFormat:
+ @"resetting while async response pending ... (%@)",
self->asyncResponseToken];
abort();
return;
[self logResponse:self->woResponse
- toRequest:self->woRequest
- connection:self->socket];
-
- if (HTTP_PERFLOG) {
+ toRequest:self->woRequest
+ connection:self->socket];
+
+ if (perfLogger) {
struct timeval tv;
gettimeofday(&tv, NULL);
self->t = (((double)tv.tv_sec) * ((double)tv.tv_usec) / 1000.0) -
- self->t;
- NSLog(@"processing of request took %4.3fs.",
- self->t < 0.0 ? -self->t : self->t);
+ self->t;
+ [perfLogger logWithFormat:@"processing of request took %4.3fs.",
+ self->t < 0.0 ? -self->t : self->t];
}
}
id request = nil;
if (self->woRequest)
- [self logWithFormat:@"WARNING: woRequest already set ???"];
+ [self warnWithFormat:@"woRequest already set ???"];
if ([self->application shouldUseSimpleHTTPParserForTransaction:self]) {
WOSimpleHTTPParser *parser;
if (self->woRequest == nil) {
ASSIGN(self->lastException, [parser lastException]);
- [self logWithFormat:@"failed to parse request: %@", self->lastException];
+ [self errorWithFormat:@"failed to parse request: %@", self->lastException];
}
[parser release];
}
[log resetReadLog];
if ([self->woRequest isCodeRedAttack]) {
- NSLog(@"WOHttpAdaptor: detected 'Code Red' request: '%@', blocking.",
- [self->woRequest uri]);
+ [self logWithFormat:
+ @"WOHttpAdaptor: detected 'Code Red' request: '%@', blocking.",
+ [self->woRequest uri]];
ASSIGN(self->woRequest, (id)nil);
return NO;
}
/* apply some adaptor headers in direct-connect mode */
[self applyAdaptorHeadersWithHttpRequest:request];
- if (HTTP_PERFLOG) {
+ if (perfLogger) {
NSTimeInterval rt;
self->requestFinishTime = [[NSDate date] timeIntervalSince1970];
rt = self->requestFinishTime - self->t;
- NSLog(@"[httpperf]: decoding of request took %4.3fs.",
- rt < 0.0 ? -1.0 : rt);
+ [perfLogger logWithFormat:@"decoding of request took %4.3fs.",
+ rt < 0.0 ? -1.0 : rt];
}
return self->woRequest ? YES : NO;
}
- (BOOL)_sendResponse {
- if (HTTP_PERFLOG) {
+ if (perfLogger) {
NSTimeInterval rt;
self->dispatchFinishTime = [[NSDate date] timeIntervalSince1970];
rt = self->dispatchFinishTime - self->requestFinishTime;
- NSLog(@"[httpperf]: dispatch of request took %4.3fs.",
- rt < 0.0 ? -1.0 : rt);
+ [perfLogger logWithFormat:@"dispatch of request took %4.3fs.",
+ rt < 0.0 ? -1.0 : rt];
}
if (self->woResponse) {
toRequest:self->woRequest
onStream:self->io];
- if (HTTP_PERFLOG) {
+ if (perfLogger) {
NSTimeInterval rt;
rt = [[NSDate date] timeIntervalSince1970] - dispatchFinishTime;
- NSLog(@"[httpperf]: delivery of request took %4.3fs.",
- rt < 0.0 ? -1.0 : rt);
+ [perfLogger logWithFormat:@"delivery of request took %4.3fs.",
+ rt < 0.0 ? -1.0 : rt];
}
}
else if (self->woRequest) {
- [self logWithFormat:
- @"ERROR: got no response for request %@ ..",
+ [self errorWithFormat:@"got no response for request %@ ..",
self->woRequest];
self->woResponse = [[self generateMissingResponse] retain];
WOResponse *response;
if ([self->asyncResponseToken length] == 0) {
- [self logWithFormat:
+ [self errorWithFormat:
@"got response ready notification (%@), "
@"but no async HTTP transaction is in progress ...",
_notification];
return;
}
if (![self->asyncResponseToken isEqual:[_notification object]]) {
- [self logWithFormat:
+ [self errorWithFormat:
@"got response ready notification (%@) for a different "
@"token (%@ vs %@) !",
_notification, self->asyncResponseToken, [_notification object]];
token = [[_response userInfo] objectForKey:WOAsyncResponseTokenKey];
if ([token length] == 0) {
- [self logWithFormat:@"missing async response token in response %@",
+ [self errorWithFormat:@"missing async response token in response %@",
_response];
return NO;
}
[parser release]; parser = nil;
}
NS_HANDLER {
- [self logWithFormat:format, localException];
+ [self errorWithFormat:format, localException];
[parser release]; parser = nil;
[localException raise];
}
/* check HTTP validity */
if ([_response status] == NGHttpStatusCode_Unauthorized) {
if ([_response headerForKey:@"www-authenticate"] == nil) {
- [self logWithFormat:
- @"WARNING: response is %i, "
- @"but no www-authenticate header is set.",
+ [self warnWithFormat:
+ @"response is %i, but no www-authenticate header is set.",
NGHttpStatusCode_Unauthorized];
}
}
e = [out lastException];
if ([e isKindOfClass:[NGSocketShutdownException class]]) {
- [self logWithFormat:disconnectError,
- _request,
- [[_response content] length],
- [e reason]];
+ [self errorWithFormat:disconnectError,
+ _request,
+ [[_response content] length],
+ [e reason]];
}
else
[e raise];
}
NS_HANDLER {
if ([localException isKindOfClass:[NGSocketShutdownException class]]) {
- [self logWithFormat:disconnectError,
+ [self errorWithFormat:disconnectError,
_request,
[[_response content] length],
[localException reason]];
}
else {
- [self logWithFormat:deliveryError, localException];
+ [self errorWithFormat:deliveryError, localException];
[out release]; out = nil; // the buffer will be flushed ..
[localException raise];
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WORequestParser.m 1 2004-08-20 10:08:27Z znek $
#include "WORequestParser.h"
#include <NGStreams/NGBufferedStream.h>
@implementation WORequestParser
+static NGLogger *logger = nil;
+
++ (void)initialize {
+ NGLoggerManager *lm;
+ static BOOL didInit = NO;
+ if (didInit)
+ return;
+ didInit = YES;
+ lm = [NGLoggerManager defaultLoggerManager];
+ logger = [lm loggerForDefaultKey:@"WORequestParserDebugEnabled"];
+ if (!logger) {
+ logger = [lm loggerForClass:self];
+ [logger setLogLevel:NGLogLevelInfo];
+ }
+}
+
- (id)initWithBufferedStream:(NGBufferedStream *)_in {
if (_in == nil) {
[self release];
return nil;
[self debugWithFormat:@"stage 1: method=%@ uri=%@ version=%@",
- method, uri, v];
-
+ method, uri, v];
+
/* headers */
if ((headers = [self parseHeaders]) == nil)
/* logging */
+- (id)logger {
+ return logger;
+}
+
- (NSString *)loggingPrefix {
return @"[http-parser]";
}
[old release];
if (self->version != nil && ![_httpVersion hasPrefix:@"HTTP/"]) {
- [self logWithFormat:
- @"WARNING: you apparently passed in an invalid HTTP version: '%@'",
+ [self warnWithFormat:
+ @"you apparently passed in an invalid HTTP version: '%@'",
_httpVersion];
}
}
NSString *s;
#if DEBUG
- [self logWithFormat:
- @"WARNING: using NSString to add a character %i,0x%08X"
+ [self warnWithFormat:
+ @"using NSString to add a character %i,0x%08X"
@"(slow, encoding=%i).", _c, _c, self->contentEncoding];
#endif
}
#endif
if (cdata == NULL) {
- NSLog(@"ERROR(%s): could not convert string non-lossy to encoding %i !",
- __PRETTY_FUNCTION__, self->contentEncoding);
+ [self errorWithFormat:
+ @"(%s): could not convert string non-lossy to encoding %i !",
+ __PRETTY_FUNCTION__, self->contentEncoding];
cdata = [_value dataUsingEncoding:self->contentEncoding
allowLossyConversion:YES];
}
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WOPageRequestHandler.m 1 2004-08-20 10:08:27Z znek $
#include <NGObjWeb/WORequestHandler.h>
pageName = @"Main";
if ((page = [app pageWithName:pageName inContext:context]) == nil) {
- [self logWithFormat:
- @"ERROR: could not create page object with name %@", pageName];
+ [self errorWithFormat:
+ @"could not create page object with name %@", pageName];
return nil;
}
apath = [WOApplication findNGObjWebResource:@"Languages" ofType:@"plist"];
if (apath == nil) {
- NSLog(@"ERROR: cannot find Languages.plist resource "
- @"of NGObjWeb library !");
+ [self errorWithFormat:@"cannot find Languages.plist resource "
+ @"of NGObjWeb library !"];
langMap = nil;
}
else
[ud registerDefaults:defs];
}
else
- NSLog(@"WARNING: did not register browser language mappings: %@", apath);
+ [self warnWithFormat:
+ @"did not register browser language mappings: %@", apath];
}
/* parse URI */
if ((ctype = [self headerForKey:@"content-type"]) != nil) {
isFormContent = [ctype hasPrefix:@"application/x-www-form-urlencoded"];
if (!isFormContent)
- isMultiPartContent = [ctype hasPrefix:@"multipart/form-data"];
+ isMultiPartContent = [ctype hasPrefix:@"multipart/form-data"];
}
if (query != nil || isFormContent || isMultiPartContent) {
/* parse query string */
if (query)
- [self _parseQueryParameters:query intoMap:self->formContent];
+ [self _parseQueryParameters:query intoMap:self->formContent];
/* parse content (if form content) */
if (isFormContent) {
- [self _parseQueryParameters:[self contentAsString]
+ [self _parseQueryParameters:[self contentAsString]
intoMap:self->formContent];
}
else if (isMultiPartContent) {
- [self logWithFormat:
- @"ERROR: missing NGHttpRequest, cannot parse multipart"];
+ [self errorWithFormat:@"missing NGHttpRequest, cannot parse multipart"];
}
[pool release];
if ([paras isKindOfClass:[NSDictionary class]])
return paras;
- [self logWithFormat:
- @"ERROR(%s): don't know how to deal with form object: %@", paras];
+ [self errorWithFormat:@"(%s): don't know how to deal with form object: %@",
+ paras];
return nil;
}
langMap = [[ud dictionaryForKey:@"WOBrowserLanguageMappings"] copy];
if (langMap == nil) {
- [self debugWithFormat:
- @"WARNING: did not find browser language mappings!"];
+ [self warnWithFormat:@"did not find browser language mappings!"];
}
}
@implementation WORequestHandler
-static BOOL doNotSetCookiePath = NO;
-static BOOL perflog = NO;
-static Class NSDateClass = Nil;
+static BOOL doNotSetCookiePath = NO;
+static Class NSDateClass = Nil;
+static NGLogger *logger = nil;
+static NGLogger *perfLogger = nil;
+ (int)version {
return 2;
}
+ (void)initialize {
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
-
+ NSUserDefaults *ud;
+ NGLoggerManager *lm;
+ static BOOL didInit = NO;
+
+ if (didInit)
+ return;
+ didInit = YES;
+
NSDateClass = [NSDate class];
- perflog = [ud boolForKey:@"WOProfileRequestHandler"];
+
+ lm = [NGLoggerManager defaultLoggerManager];
+ logger = [lm loggerForClass:self];
+ perfLogger = [lm loggerForDefaultKey:@"WOProfileRequestHandler"];
+
+ ud = [NSUserDefaults standardUserDefaults];
doNotSetCookiePath = [ud boolForKey:@"WOUseGlobalCookiePath"];
}
}
}
- if (perflog)
+ if (perfLogger)
startHandling = [[NSDateClass date] timeIntervalSince1970];
thread = [NSThread currentThread];
{
/* setup context */
context = [WOContext contextWithRequest:_request];
- NSAssert(context, @"no context assigned ..");
+ NSAssert(context, @"no context assigned ..");
[app _setCurrentContext:context];
/* check session id */
if (session != nil) {
if ([session storesIDsInCookies]) {
- [self debugWithFormat:@"add cookie to session: %@", session];
+ [self debugWithFormat:@"add cookie to session: %@", session];
[self addCookiesForSession:session
toResponse:response
inContext:context];
withResponse:response
application:app];
}
- else
- [self debugWithFormat:@"no session to store."];
+ else
+ [self debugWithFormat:@"no session to store."];
}
NS_HANDLER {
response = [app handleException:localException inContext:context];
[app lock];
if ([app isRefusingNewSessions] &&
([app activeSessionsCount] < [app minimumActiveSessionsCount])) {
- [self debugWithFormat:
+ [self logWithFormat:
@"application terminates because it refuses new sessions and "
@"the active session count (%i) is below the minimum (%i).",
[app activeSessionsCount], [app minimumActiveSessionsCount]];
}
[app unlock];
- if (perflog) {
+ if (perfLogger) {
NSTimeInterval rt;
rt = [[NSDateClass date] timeIntervalSince1970] - startHandling;
- [self debugWithFormat:@"handleRequest took %4.3fs.", rt < 0.0 ? -1.0 : rt];
+ [perfLogger logWithFormat:@"handleRequest took %4.3fs.",
+ rt < 0.0 ? -1.0 : rt];
}
return [response autorelease];
return nil;
}
+/* logging */
+
+- (id)logger {
+ return logger;
+}
+
@end /* WORequestHandler */
@implementation WORequestHandler(Cookies)
- (id)initWithPath:(NSString *)_path {
#if __APPLE__
if ([_path length] == 0) {
- NSLog(@"ERROR(%s): missing path!", __PRETTY_FUNCTION__);
+ [self errorWithFormat:@"(%s): missing path!", __PRETTY_FUNCTION__];
/* this doesn't work with subclasses which do not require a path ... */
#if 0
[self release];
fm = [self fileManager];
if ([self->base length] > 0) {
if (![fm fileExistsAtPath:self->base]) {
- NSLog(@"WARNING(%s): Resources base path '%@' does not exist !",
- __PRETTY_FUNCTION__, self->base);
+ [self warnWithFormat:@"(%s): Resources base path '%@' does not exist !",
+ __PRETTY_FUNCTION__, self->base];
return nil;
}
}
if ([self->resources length] > 0) {
if (![fm fileExistsAtPath:self->resources]) {
- [self debugWithFormat:
- @"WARNING(%s): Resources path %@ does not exist !",
+ [self warnWithFormat:
+ @"(%s): Resources path %@ does not exist !",
__PRETTY_FUNCTION__, self->resources];
[self->resources release]; self->resources = nil;
}
static BOOL didLog = NO;
if (!didLog) {
didLog = YES;
- [self debugWithFormat:
- @"WARNING(%s): WebServerResources path '%@' does not exist !",
+ [self warnWithFormat:
+ @"(%s): WebServerResources path '%@' does not exist !",
__PRETTY_FUNCTION__, self->w3resources];
}
[self->w3resources release]; self->w3resources = nil;
if (_name == nil) {
#if DEBUG
- NSLog(@"WARNING(%s): tried to get path to component with <nil> name !",
- __PRETTY_FUNCTION__);
+ [self warnWithFormat:
+ @"(%s): tried to get path to component with <nil> name !",
+ __PRETTY_FUNCTION__];
#endif
return nil;
}
}
if (!isDirectory) {
- NSLog(@"WARNING(%s): language entry %@ is not a directory !",
- __PRETTY_FUNCTION__, languagePath);
+ [self warnWithFormat:@"(%s): language entry %@ is not a directory !",
+ __PRETTY_FUNCTION__, languagePath];
if (doesCache && (compoundKey != nil)) {
// register null in cache, so that we know it's non-existent
NSMapInsert(self->componentDefinitions, compoundKey, null);
baseURL:[NSURL URLWithString:baseUrl]
frameworkName:nil];
if (cdef == nil) {
- NSLog(@"WARNING(%s): could not load component definition of "
- @"'%@' from language project: %@",
- __PRETTY_FUNCTION__, _name, languagePath);
+ [self warnWithFormat:
+ @"(%s): could not load component definition of "
+ @"'%@' from language project: %@",
+ __PRETTY_FUNCTION__, _name, languagePath];
if (doesCache && (compoundKey != nil)) {
// register null in cache, so that we know it's non-existent
NSMapInsert(self->componentDefinitions, compoundKey, null);
baseURL:[NSURL URLWithString:baseUrl]
frameworkName:nil];
if (cdef == nil) {
- NSLog(@"WARNING(%s): could not load component definition of '%@' from "
- @"component wrapper: '%@'",
- __PRETTY_FUNCTION__, _name, componentURL);
+ [self warnWithFormat:
+ @"(%s): could not load component definition of '%@' from "
+ @"component wrapper: '%@'",
+ __PRETTY_FUNCTION__, _name, componentURL];
if (doesCache) {
/* register null in cache, so that we know it's non-existent */
NSMapInsert(self->componentDefinitions, componentURL, null);
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WORunLoop.m 1 2004-08-20 10:08:27Z znek $
#include "WORunLoop.h"
#include "common.h"
#if 0
typedef enum {
- NSPosixNoActivity = 0,
- NSPosixReadableActivity = 1,
- NSPosixWritableActivity = 2,
- NSPosixExceptionalActivity = 4
+ NSPosixNoActivity = 0,
+ NSPosixReadableActivity = 1,
+ NSPosixWritableActivity = 2,
+ NSPosixExceptionalActivity = 4
} NSPosixFileActivities;
#endif
@"NSFileObjectBecameActiveNotificationName";
static char *activityDesc[8] = {
- "---", // 0
- "--R", // 1
- "-W-", // 2
- "-WR", // 3
- "E--", // 4
- "E-R", // 5
- "EW-", // 6
- "EWR" // 7
+ "---", // 0
+ "--R", // 1
+ "-W-", // 2
+ "-WR", // 3
+ "E--", // 4
+ "E-R", // 5
+ "EW-", // 6
+ "EWR" // 7
};
@interface WORunLoopFileObjectInfo : NSObject
{
- id fileObject;
- NSPosixFileActivities watchedActivities;
- BOOL canCheckAlive;
+ id fileObject;
+ NSPosixFileActivities watchedActivities;
+ BOOL canCheckAlive;
}
- (id)initWithFileObject:(id)_fileObject
}
- (id)init
{
- NSLog(@"ERROR: do not use init with WORunLoopFileObjectInfo ..");
- AUTORELEASE(self);
- return nil;
+ [self errorWithFormat:@"do not use init with WORunLoopFileObjectInfo .."];
+ AUTORELEASE(self);
+ return nil;
}
- (void)dealloc
{
- RELEASE(self->fileObject); self->fileObject = nil;
- [super dealloc];
+ RELEASE(self->fileObject); self->fileObject = nil;
+ [super dealloc];
}
- (BOOL)isEqual:(WORunLoopFileObjectInfo*)otherInfo
{
- return [self->fileObject isEqual:otherInfo->fileObject];
+ return [self->fileObject isEqual:otherInfo->fileObject];
}
- (BOOL)isAlive {
- return (self->canCheckAlive) ? [self->fileObject isAlive] : YES;
+ return (self->canCheckAlive) ? [self->fileObject isAlive] : YES;
}
- (int)fileDescriptor
{
- return [self->fileObject fileDescriptor];
+ return [self->fileObject fileDescriptor];
}
- (NSPosixFileActivities)watchedActivities
{
- return self->watchedActivities;
+ return self->watchedActivities;
}
- (void)activity:(NSPosixFileActivities)_activity onDescriptor:(int)_fd
{
- //NSLog(@"FileObject %@ was active ..", self->fileObject);
+ //NSLog(@"FileObject %@ was active ..", self->fileObject);
- [[NSNotificationCenter defaultCenter]
- postNotificationName:
- NSFileObjectBecameActiveNotificationName
- object:self->fileObject];
+ [[NSNotificationCenter defaultCenter]
+ postNotificationName:
+ NSFileObjectBecameActiveNotificationName
+ object:self->fileObject];
}
- (NSString *)description
{
- return [NSString stringWithFormat:
- @"<%@[0x%08X]: object=%@ actitivity=%s>",
- NSStringFromClass([self class]), self,
- self->fileObject,
- activityDesc[self->watchedActivities]
- ];
+ return [NSString stringWithFormat:
+ @"<%@[0x%08X]: object=%@ actitivity=%s>",
+ NSStringFromClass([self class]), self,
+ self->fileObject,
+ activityDesc[self->watchedActivities]
+ ];
}
@end
+ (NSRunLoop *)currentRunLoop
{
- if (taskIsMultithreaded) {
- NSLog(@"WORunLoop does not work multithreaded, exit ..");
- return nil;
- }
- else {
- if (!currentRunLoop)
+ if (taskIsMultithreaded) {
+ NSLog(@"WORunLoop does not work multithreaded, exit ..");
+ return nil;
+ }
+ else {
+ if (!currentRunLoop)
currentRunLoop = [[self alloc] init];
- return currentRunLoop;
- }
+ return currentRunLoop;
+ }
}
- (id)init {
}
}
if (r > 0) {
- NSLog(@"WARNING: could not resolve all activities (%i) ..",
+ [self warnWithFormat:@"could not resolve all activities (%i) ..",
r);
}
}
NS_HANDLER {
- NSLog(format, __PRETTY_FUNCTION__,
- [localException name], [localException reason]);
+ [self errorWithFormat:format, __PRETTY_FUNCTION__,
+ [localException name], [localException reason]];
}
NS_ENDHANDLER;
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
+// $Id: WOServerSessionStore.m 1 2004-08-20 10:08:27Z znek $
#include <NGObjWeb/WOSessionStore.h>
return nil;
if (![_sid isKindOfClass:[NSString class]]) {
- [self logWithFormat:
- @"WARNING(%s): got invalid session id (expected string !): %@",
+ [self warnWithFormat:@"%s: got invalid session id (expected string !): %@",
__PRETTY_FUNCTION__, _sid];
return nil;
}
self->readBytes = (void *)
[(NSObject *)self->io methodForSelector:@selector(readBytes:count:)];
if (self->readBytes == NULL) {
- NSLog(@"WARNING(%s): got invalid stream object: %@", __PRETTY_FUNCTION__,
- self->io);
+ [self warnWithFormat:@"(%s): got invalid stream object: %@",
+ __PRETTY_FUNCTION__,
+ self->io];
[self release];
return nil;
}
static BOOL didLog = NO;
if (!didLog) {
didLog = YES;
- NSLog(@"WARNING(%s): reallocated the HTTP line buffer %i times, "
- @"consider increasing the default line buffer size!",
- __PRETTY_FUNCTION__, reallocCount);
+ [self warnWithFormat:@"(%s): reallocated the HTTP line buffer %i times, "
+ @"consider increasing the default line buffer size!",
+ __PRETTY_FUNCTION__, reallocCount];
}
}
if (*p == ' ' || *p == '\t') {
// TODO: implement folding (remember last header-key, add string)
- [self logWithFormat:
- @"ERROR(%s): got a folded HTTP header line, cannot process!",
- __PRETTY_FUNCTION__];
+ [self errorWithFormat:
+ @"(%s): got a folded HTTP header line, cannot process!",
+ __PRETTY_FUNCTION__];
continue;
}
/* find key/value separator */
if ((v = index(p, ':')) == NULL) {
- [self logWithFormat:@"WARNING: got malformed header line: '%s'",
- self->lineBuffer];
+ [self warnWithFormat:@"got malformed header line: '%s'",
+ self->lineBuffer];
continue;
}
readToEOF = NO;
if (readToEOF) {
- [self logWithFormat:
- @"WARNING: not processing entity of request "
- @"without contentlen!"];
+ [self warnWithFormat:
+ @"not processing entity of request without contentlen!"];
}
}
}
fn = [[NSProcessInfo processInfo] temporaryFileName];
if ((t = fopen([fn cString], "w")) == NULL) {
- [self logWithFormat:@"ERROR: could not open temporary file '%@'!", fn];
+ [self errorWithFormat:@"could not open temporary file '%@'!", fn];
/* read into memory as a fallback ... */
else {
q = [self->qualifiers objectAtIndex:0];
if (cnt != 1) {
- [self logWithFormat:@"WARNING: to many subqualifiers in not !: %@",
+ [self warnWithFormat:@"too many subqualifiers in not !: %@",
self->qualifiers];
}
}
[self->qualifiers release]; self->qualifiers = nil;
if ((stackSize = [self->compoundQualStack count]) == 0) {
- [self logWithFormat:@"ERROR: the qualifier stack is mixed up !"];
+ [self errorWithFormat:@"the qualifier stack is mixed up !"];
}
else if (stackSize > 1) {
/* this one was not the root qualifier */
[self->propSet setObject:t forKey:fqn];
else {
[self->propSet setObject:[NSNull null] forKey:fqn];
- [self logWithFormat:
- @"ERROR: lost the parsing cdata (broken nesting) ?!"];
+ [self errorWithFormat:@"lost the parsing cdata (broken nesting) ?!"];
}
[t release];
}
for (i = 0, didReplace = NO; i < len; i++) {
if (buf[i] != '%') {
if (buf[i] == '*') {
- NSLog(@"WARNING(%s): SQL string contains a '*': %@",
- __PRETTY_FUNCTION__, _sql);
+ [self warnWithFormat:@"(%s): SQL string contains a '*': %@",
+ __PRETTY_FUNCTION__, _sql];
}
continue;
}
NSLog(@" FS: %@", fs);
if (fs == nil) {
- NSLog(@" ERROR: could not parse SQL: %@", sql);
+ [self errorWithFormat:@" could not parse SQL: %@", sql];
}
else {
EOQualifier *q;
url = [self baseURL];
}
else {
- [self logWithFormat:
- @"WARNING: unable to calculate davURL for this object !"];
+ [self warnWithFormat:@"unable to calculate davURL for this object !"];
url = nil;
}
if (url == nil)
- [self logWithFormat:@"WARNING: got no davURL for this object !"];
+ [self warnWithFormat:@"got no davURL for this object !"];
return url;
}
If the results came from SoObjectDataSource this is possible because
the "full" object is none in the SoObjectResultEntry.
*/
- [self logWithFormat:
- @"WARNING: attempted deep-search, not supported yet."];
+ [self warnWithFormat:@"attempted deep-search, not supported yet."];
}
result = ma;
}
/* simple key, just use -lookupName */
child = [self lookupName:key inContext:_ctx acquire:NO];
if (child == nil) {
- [self logWithFormat:@"ERROR: did not find the BPROPFIND target '%@'",
- key];
+ [self errorWithFormat:@"did not find the BPROPFIND target '%@'", key];
continue;
}
}
// TODO: pass auth parameters to traversal context !!
child = [self traversePath:key acquire:NO];
if (child == nil) {
- [self logWithFormat:
- @"ERROR: did not find the BPROPFIND target '%@' by traversing.",
- key];
+ [self errorWithFormat:
+ @"did not find the BPROPFIND target '%@' by traversing.",
+ key];
continue;
}
if ([child isKindOfClass:[NSException class]]) {
if ([scope hasPrefix:@"deep"])
return [self performWebDAVDeepQuery:_fs inContext:_ctx];
- [self logWithFormat:@"ERROR: called with invalid scope '%@'", scope];
+ [self errorWithFormat:@"called with invalid scope '%@'", scope];
return nil;
}
setProps = [setProps autorelease];
if (delProps == nil && setProps == nil) {
- [self logWithFormat:@"WARNING: got no properties in PROPPATCH !"];
+ [self warnWithFormat:@"got no properties in PROPPATCH !"];
return [self httpException:400 /* bad request */
reason:@"got no properties in PROPPATCH !"];
}
ifValue = [rq headerForKey:@"if"];
if (lockDepth != nil && ![lockDepth isEqualToString:@"0"]) {
- [self logWithFormat:
- @"WARNING: 'depth' locking not supported yet (depth=%@)!",
- lockDepth];
+ [self warnWithFormat:@"'depth' locking not supported yet (depth=%@)!",
+ lockDepth];
}
if (ifValue) {
- [self logWithFormat:
- @"WARNING: 'if' locking not supported yet, if: '%@'", ifValue];
+ [self warnWithFormat:@"'if' locking not supported yet, if: '%@'", ifValue];
}
// need to parse lockinfo
NSURL *url;
if ((url = [NSURL URLWithString:[callback stringValue]]) == nil) {
- [self debugWithFormat:@"ERROR: could not parse callback URL '%@'",
+ [self errorWithFormat:@"could not parse callback URL '%@'",
callback];
return [self httpException:400 /* Bad Request */
reason:@"missing valid callback URL !"];
if (debugBulkTarget) [self logWithFormat:@"path: %@", target];
}
else {
- [self logWithFormat:@"ERROR: could not parse BPROPFIND target '%@' !",
- target];
+ [self errorWithFormat:@"could not parse BPROPFIND target '%@' !",
+ target];
}
}
/* setup the "subrequest" */
if ([targetURL isAbsoluteURL]) {
- NSURL *url;
-
- if ((url = [NSURL URLWithString:targetURL]))
- targetURL = [url path];
- else {
- [self logWithFormat:@"ERROR: could not parse target-url '%@'",
- targetURL];
- }
+ NSURL *url;
+
+ if ((url = [NSURL URLWithString:targetURL]))
+ targetURL = [url path];
+ else {
+ [self errorWithFormat:@"could not parse target-url '%@'", targetURL];
+ }
}
localRequest = [[WORequest alloc] initWithMethod:@"PROPFIND"
content:nil
userInfo:nil];
localContext =
- [[[WOContext alloc] initWithRequest:localRequest] autorelease];
+ [[[WOContext alloc] initWithRequest:localRequest] autorelease];
[localRequest autorelease];
/* resetup fetchspec */
error:&e
acquire:NO];
if (targetObject == nil) {
- [self logWithFormat:@"did not find BPROPFIND target: %@", targetURL];
- [self logWithFormat:@" root: %@", [_ctx traversalRoot]];
- [self logWithFormat:@" path: %@",
+ [self logWithFormat:@"did not find BPROPFIND target: %@", targetURL];
+ [self logWithFormat:@" root: %@", [_ctx traversalRoot]];
+ [self logWithFormat:@" path: %@",
[[localRequest requestHandlerPathArray]
componentsJoinedByString:@"/"]];
- [self logWithFormat:@" error: %@", e];
- targetResult = e;
+ [self logWithFormat:@" error: %@", e];
+ targetResult = e;
}
else {
- /* perform query */
+ /* perform query */
- targetResult = [targetObject performWebDAVQuery:fs
- inContext:localContext];
- if (targetResult == nil) {
- targetResult =
- [self httpException:500 /* Server Error */
- reason:@"could not perform query (object returned nil)"];
- }
+ targetResult = [targetObject performWebDAVQuery:fs
+ inContext:localContext];
+ if (targetResult == nil) {
+ targetResult =
+ [self httpException:500 /* Server Error */
+ reason:@"could not perform query (object returned nil)"];
+ }
}
// do we need to distinguish the queries somehow ? (href generation)
if ([targetResult isKindOfClass:[NSArray class]])
- [result addObjectsFromArray:targetResult];
+ [result addObjectsFromArray:targetResult];
else if (targetResult)
- [result addObject:targetResult];
-
+ [result addObject:targetResult];
+
[pool release];
}
}
return YES;
}
- [self logWithFormat:@"ERROR: don't know how to render: %@", _object];
+ [self errorWithFormat:@"don't know how to render: %@", _object];
return NO;
}
if (href == nil) {
if (debugOn) {
- [self logWithFormat:
- @"WARNING: using baseURL for href, "
- @"entry did not provide a URL: %@", baseURL];
+ [self warnWithFormat:
+ @"using baseURL for href, entry did not provide a URL: %@",
+ baseURL];
}
href = [baseURL stringValue];
}
if ((key = [_propMap objectForKey:@"{DAV:}href"]) != nil) {
if ((href = [entry valueForKey:key]) == nil) {
if (debugOn) {
- [self debugWithFormat:
- @"WARNING: no value for {DAV:}href key '%@': %@",
- key, entry];
+ [self warnWithFormat:
+ @"no value for {DAV:}href key '%@': %@", key, entry];
}
}
}
else if (debugOn) {
- [self debugWithFormat:
- @"WARNING: no key for {DAV:}href in property map !"];
+ [self warnWithFormat:@"no key for {DAV:}href in property map !"];
}
}
if ((stat = [entry valueForKey:@"{DAV:}status"]) == nil) {
if (formatOutput) [r appendContentCharacter:'\n'];
}
else {
- [self logWithFormat:
- @"WARNING: WebDAV result entry has no valid href: %@", entry];
+ [self warnWithFormat:@"WebDAV result entry has no valid href: %@", entry];
}
[r appendContentString:@"<D:propstat>"];
);
buildSettings = {
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 4.5.84;
+ DYLIB_CURRENT_VERSION = 4.5.91;
FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks";
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = NO;
/* If file was not a dictionary, then it's a standard strings file */
if ((sdata = [[NSData alloc] initWithContentsOfFile:self->path]) == nil) {
- [self debugWithFormat:@"ERROR: could not read strings file: %@",
- self->path];
+ [self errorWithFormat:@"could not read strings file: %@", self->path];
self->data = nil;
return;
}
tmp = [[NSString alloc] initWithData:sdata encoding:stringFilesEncoding];
[sdata release]; sdata = nil;
if (tmp == nil) {
- [self logWithFormat:@"ERROR: file is not in required encoding (%d): %@",
- stringFilesEncoding, self->path];
+ [self errorWithFormat:@"file is not in required encoding (%d): %@",
+ stringFilesEncoding, self->path];
self->data = nil;
return;
}
NS_DURING {
if ((plist = [tmp propertyListFromStringsFileFormat]) == nil) {
- NSLog(@"%s: could not load strings file '%@'",
- __PRETTY_FUNCTION__,
- self->path);
+ [self errorWithFormat:@"%s: could not load strings file '%@'",
+ __PRETTY_FUNCTION__,
+ self->path];
}
[tmp release]; tmp = nil;
self->data = [plist copy];
#endif
#define IS_DEPRECATED \
- NSLog(@"WARNING: used deprecated method: %s:%i.", \
- __PRETTY_FUNCTION__, __LINE__);
+ [self warnWithFormat:@"used deprecated method: %s:%i.", \
+ __PRETTY_FUNCTION__, __LINE__];
#if PROFILE
# define BEGIN_PROFILE \
+2004-11-18 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * v4.5.134
+
+ * NGLogging: updated
+
+ * NGExtensions/NSObject+Logs.h, FdExt.subproj/NSObject+Logs.m:
+ changed existing implementation to use NGLogging by default. Added
+ some more methods to support different log levels. Also added
+ -logger and -debugLogger which are used to provide the default
+ loggers for the desired purpose.
+
+ * FdExt.subproj/NGBundleManager.m: fixed wrong include
+
2004-11-17 Helge Hess <helge.hess@opengroupware.org>
* NGBundleManager.m: fixed a bug in the bundle type check when the
*/
#include "NSObject+Logs.h"
+#include "NGLoggerManager.h"
+#include "NGLogger.h"
#include "common.h"
@implementation NSObject(NGLogs)
return NO;
#endif
}
+
+- (id)logger {
+ static id logger = nil;
+
+ if (logger == nil) {
+ NGLoggerManager *lm;
+
+ lm = [NGLoggerManager defaultLoggerManager];
+ logger = [lm loggerForClass:[self class]];
+ }
+ return logger;
+}
+
+- (id)debugLogger {
+ return [self logger];
+}
+
- (NSString *)loggingPrefix {
/* improve perf ... */
return [NSStringClass() stringWithFormat:@"<0x%08X[%@]>",
self, NSStringFromClass([self class])];
}
-- (void)logWithFormat:(NSString *)_format arguments:(va_list)ap {
- NSString *value = nil;
-
- value = [[NSStringClass() alloc] initWithFormat:_format arguments:ap];
- NSLog(@"%@ %@", [self loggingPrefix], value);
- [value release];
-}
-- (void)debugWithFormat:(NSString *)_format arguments:(va_list)ap {
+- (void)debugWithFormat:(NSString *)_fmt arguments:(va_list)_va {
#if DEBUG
- NSString *value = nil;
+ NSString *msg;
if (![self isDebuggingEnabled]) return;
- value = [[NSStringClass() alloc] initWithFormat:_format arguments:ap];
- NSLog(@"<%@>D %@", [self loggingPrefix], value);
- [value release];
+ msg = [[NSStringClass() alloc] initWithFormat:_fmt arguments:_va];
+ [[self debugLogger] debugWithFormat:@"<%@>D %@", [self loggingPrefix], msg];
+ [msg release];
#else
# warning debug is disabled, debugWithFormat wont print anything ..
#endif
}
-- (void)logWithFormat:(NSString *)_format, ... {
+- (void)logWithFormat:(NSString *)_fmt arguments:(va_list)_va {
+ NGLogger *logger;
+ NSString *msg;
+
+ logger = [self logger];
+ if (![logger isLogInfoEnabled]) return;
+
+ msg = [[NSStringClass() alloc] initWithFormat:_fmt arguments:_va];
+ [logger logWithFormat:@"%@ %@", [self loggingPrefix], msg];
+ [msg release];
+}
+
+- (void)warnWithFormat:(NSString *)_fmt arguments:(va_list)_va {
+ NGLogger *logger;
+ NSString *msg;
+
+ logger = [self logger];
+ if (![logger isLogWarnEnabled]) return;
+
+ msg = [[NSStringClass() alloc] initWithFormat:_fmt arguments:_va];
+ [logger warnWithFormat:@"%@ %@", [self loggingPrefix], msg];
+ [msg release];
+}
+
+- (void)errorWithFormat:(NSString *)_fmt arguments:(va_list)_va {
+ NGLogger *logger;
+ NSString *msg;
+
+ logger = [self logger];
+ if (![logger isLogErrorEnabled]) return;
+
+ msg = [[NSStringClass() alloc] initWithFormat:_fmt arguments:_va];
+ [logger errorWithFormat:@"%@ %@", [self loggingPrefix], msg];
+ [msg release];
+}
+
+- (void)fatalWithFormat:(NSString *)_fmt arguments:(va_list)_va {
+ NGLogger *logger;
+ NSString *msg;
+
+ logger = [self logger];
+ if (![logger isLogFatalEnabled]) return;
+
+ msg = [[NSStringClass() alloc] initWithFormat:_fmt arguments:_va];
+ [logger fatalWithFormat:@"%@ %@", [self loggingPrefix], msg];
+ [msg release];
+}
+
+- (void)debugWithFormat:(NSString *)_fmt, ... {
+ va_list ap;
+
+ va_start(ap, _fmt);
+ [self debugWithFormat:_fmt arguments:ap];
+ va_end(ap);
+}
+- (void)logWithFormat:(NSString *)_fmt, ... {
+ va_list ap;
+
+ va_start(ap, _fmt);
+ [self logWithFormat:_fmt arguments:ap];
+ va_end(ap);
+}
+- (void)warnWithFormat:(NSString *)_fmt, ... {
+ va_list ap;
+
+ va_start(ap, _fmt);
+ [self warnWithFormat:_fmt arguments:ap];
+ va_end(ap);
+}
+- (void)errorWithFormat:(NSString *)_fmt, ... {
va_list ap;
- va_start(ap, _format);
- [self logWithFormat:_format arguments:ap];
+ va_start(ap, _fmt);
+ [self errorWithFormat:_fmt arguments:ap];
va_end(ap);
}
-- (void)debugWithFormat:(NSString *)_format, ... {
+- (void)fatalWithFormat:(NSString *)_fmt, ... {
va_list ap;
- va_start(ap, _format);
- [self debugWithFormat:_format arguments:ap];
+ va_start(ap, _fmt);
+ [self fatalWithFormat:_fmt arguments:ap];
va_end(ap);
}
NGLogging_HEADER_FILES = \
NGLogging.h \
+ NGLogLevel.h \
NGLogger.h \
NGLoggerManager.h \
NGLogEvent.h \
NGLogAppender.h \
NGLogConsoleAppender.h \
NGLogSyslogAppender.h \
- NSObject+ExtendedLogging.h \
libNGExtensions_HEADER_FILES += \
#include "NGBundleManager.h"
#include "common.h"
#include <NGExtensions/NSObject+Logs.h>
-#include <NGExtensions/NSNull+Misc.h>
+#include <NGExtensions/NSNull+misc.h>
#import <Foundation/NSFileManager.h>
#import <EOControl/EOQualifier.h>
#include <ctype.h>
indentWidth = 2;
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.h;
- path = "NSObject+ExtendedLogging.h";
- refType = 4;
- sourceTree = "<group>";
- };
- ADCD51450743BBE10071C1A1 = {
- fileEncoding = 5;
- indentWidth = 2;
- isa = PBXFileReference;
- lastKnownFileType = sourcecode.c.objc;
- path = "NSObject+ExtendedLogging.m";
+ path = NGLogLevel.h;
refType = 4;
sourceTree = "<group>";
};
);
};
};
- ADCD51540743BBE10071C1A1 = {
- fileRef = ADCD51450743BBE10071C1A1;
- isa = PBXBuildFile;
- settings = {
- };
- };
ADCD51570743BBE60071C1A1 = {
children = (
ADCD51380743BBE10071C1A1,
ADCD515A0743BBF00071C1A1 = {
children = (
ADCD51410743BBE10071C1A1,
+ ADCD51440743BBE10071C1A1,
ADCD513F0743BBE10071C1A1,
ADCD52020743D8CA0071C1A1,
ADCD513D0743BBE10071C1A1,
ADCD51390743BBE10071C1A1,
ADCD513B0743BBE10071C1A1,
ADCD51420743BBE10071C1A1,
- ADCD51440743BBE10071C1A1,
);
fileEncoding = 5;
indentWidth = 2;
ADCD513A0743BBE10071C1A1,
ADCD513C0743BBE10071C1A1,
ADCD51430743BBE10071C1A1,
- ADCD51450743BBE10071C1A1,
);
isa = PBXGroup;
name = Classes;
ADCD514D0743BBE10071C1A1,
ADCD514F0743BBE10071C1A1,
ADCD51520743BBE10071C1A1,
- ADCD51540743BBE10071C1A1,
ADCD52050743D8CA0071C1A1,
);
isa = PBXSourcesBuildPhase;
);
buildSettings = {
DYLIB_COMPATIBILITY_VERSION = 1;
- DYLIB_CURRENT_VERSION = 4.5.127;
+ DYLIB_CURRENT_VERSION = 4.5.134;
FRAMEWORK_SEARCH_PATHS = "$(LOCAL_LIBRARY_DIR)/Frameworks";
FRAMEWORK_VERSION = A;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
#include <NGExtensions/NSMethodSignature+misc.h>
#include <NGExtensions/NSNull+misc.h>
#include <NGExtensions/NSObject+Logs.h>
+#include <NGExtensions/NGLogging.h>
#include <NGExtensions/NSObject+Values.h>
#include <NGExtensions/NSProcessInfo+misc.h>
#include <NGExtensions/NSSet+enumerator.h>
*/
#import <Foundation/NSObject.h>
-#include <NGExtensions/NSObject+ExtendedLogging.h> /* for LogLevel */
+#include <NGExtensions/NGLogLevel.h>
@class NGLogEvent;
#import <Foundation/NSObject.h>
#import <Foundation/NSDate.h>
-
-#include <NGExtensions/NSObject+ExtendedLogging.h> /* for NGLogLevel */
+#include <NGExtensions/NGLogLevel.h>
@class NSString;
--- /dev/null
+/*
+ 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.
+*/
+
+#ifndef __NGExtensions_NGLogLevel_H_
+#define __NGExtensions_NGLogLevel_H_
+
+/*
+ Currently defined log levels.
+*/
+
+typedef enum {
+ NGLogLevelOff = 0,
+ NGLogLevelFatal = 1,
+ NGLogLevelError = 2,
+ NGLogLevelWarn = 3,
+ NGLogLevelInfo = 4,
+ NGLogLevelDebug = 5,
+ NGLogLevelAll = 6
+} NGLogLevel;
+
+#endif /* __NGExtensions_NGLogLevel_H_ */
*/
#import <Foundation/NSObject.h>
-#include <NGExtensions/NSObject+ExtendedLogging.h>
+#include <NGExtensions/NGLogLevel.h>
@interface NGLogger : NSObject
{
- (void)setLogLevel:(NGLogLevel)_level;
- (NGLogLevel)logLevel;
+
+
/* logging */
-- (void)logLevel:(NGLogLevel)_level message:(NSString *)_msg;
-- (void)logLevel:(NGLogLevel)_level withFormat:(NSString *)_fmt, ...;
+/* conditions */
+
+- (BOOL)isDebuggingEnabled;
+- (BOOL)isLogInfoEnabled;
+- (BOOL)isLogWarnEnabled;
+- (BOOL)isLogErrorEnabled;
+- (BOOL)isLogFatalEnabled;
+
@end
#endif /* __NGExtensions_NGLogger_H_ */
/* Retrieves a logger conditional to the existence of the given default key.
In order to stay backwards compatible to existing applications, a boolean
value auf YES associated with this key sets the default log level of this
- logger to NGLogLevelDebug. Other possible values for this key include
- "DEBUG, "INFO", "WARN", "ERROR" and "FATAL". Everything else will be mapped
- to NGLogLevelAll. If the requested default key is not set, *nil* is
+ logger to NGLogLevelDebug. If the requested default key is not set, *nil* is
returned.
*/
- (NGLogger *)loggerForDefaultKey:(NSString *)_defaultKey;
Documentation is currently provided in the headers only.
*/
-#include <NGExtensions/NSObject+ExtendedLogging.h>
+#include <NGExtensions/NGLogLevel.h>
#include <NGExtensions/NGLogger.h>
#include <NGExtensions/NGLoggerManager.h>
#include <NGExtensions/NGLogEvent.h>
+++ /dev/null
-/*
- 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.
-*/
-
-#ifndef __NSObject_ExtendedLogging_H_
-#define __NSObject_ExtendedLogging_H_
-
-/*
- Logging convenience for the new NGLogger based API.
-
- The default implementation uses the "NGDefaultLogLevel" user default key to
- retrieve a logger from the NGLoggerManager. If this default isn't set,
- a default logger with log level NGLogLevelInfo will be instantiated.
-
- Consult the header of NGLoggerManager for further details on setting the
- "NGDefaultLogLevel" user default.
-*/
-
-#import <Foundation/NSObject.h>
-
-typedef enum {
- NGLogLevelOff = 0,
- NGLogLevelFatal = 1,
- NGLogLevelError = 2,
- NGLogLevelWarn = 3,
- NGLogLevelInfo = 4,
- NGLogLevelDebug = 5,
- NGLogLevelAll = 6
-} NGLogLevel;
-
-@interface NSObject(NGExtendedLogging)
-
-+ (id)logger;
-- (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, ...;
-
-@end
-
-#endif /* __NSObject_ExtendedLogging_H_ */
/*
- Copyright (C) 2000-2003 SKYRIX Software AG
+ Copyright (C) 2000-2004 SKYRIX Software AG
- This file is part of OGo
+ 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, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#ifndef __NGExtensions_NSObject_Logs_H__
#define __NGExtensions_NSObject_Logs_H__
@interface NSObject(NGLogs)
+/* default loggers for object */
+- (id)logger;
+- (id)debugLogger;
+
/* "end user" methods, variable argument logging methods .. */
-- (void)logWithFormat:(NSString *)_format, ...;
-- (void)debugWithFormat:(NSString *)_format, ...;
+- (void)debugWithFormat:(NSString *)_fmt, ...;
+- (void)logWithFormat:(NSString *)_fmt, ...;
+- (void)warnWithFormat:(NSString *)_fmt, ...;
+- (void)errorWithFormat:(NSString *)_fmt, ...;
+- (void)fatalWithFormat:(NSString *)_fmt, ...;
/* prefix, override that, to make a special logging prefix */
- (NSString *)loggingPrefix;
- (BOOL)isDebuggingEnabled;
/*"designated" logging methods */
-- (void)logWithFormat:(NSString *)format arguments:(va_list)argList;
-- (void)debugWithFormat:(NSString *)format arguments:(va_list)argList;
+- (void)debugWithFormat:(NSString *)_fmt arguments:(va_list)_va;
+- (void)logWithFormat:(NSString *)_fmt arguments:(va_list)_va;
+- (void)warnWithFormat:(NSString *)_fmt arguments:(va_list)_va;
+- (void)errorWithFormat:(NSString *)_fmt arguments:(va_list)_va;
+- (void)fatalWithFormat:(NSString *)_fmt arguments:(va_list)_va;
@end
+2004-11-18 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * NGLogLevel.h: new header bearing the log levels
+
+ * NSObject+ExtendedLogging.[hm]: removed. All equivalent functionality
+ is now in NSObject+Logs.[hm].
+
+ * NGLogger.[hm]: changed API to that required by NSObject+Logs.m.
+
2004-11-17 Marcus Mueller <znek@mulle-kybernetik.com>
* *.h: provided some documentation
NGLogEvent.m \
NGLogAppender.m \
NGLogConsoleAppender.m \
- NSObject+ExtendedLogging.m \
# TODO: disable on Windows
NGLogging_OBJC_FILES += \
*/
#include "NGLogAppender.h"
-#include "NSObject+ExtendedLogging.h"
+#include "NGLogLevel.h"
#include "NGLogEvent.h"
#include "common.h"
[self subclassResponsibility:_cmd];
#else
NSLog(@"ERROR(%s): method should be implemented by subclass!",
- __PRETTY_FUNCTION__);
+ __PRETTY_FUNCTION__);
#endif
}
- (NSString *)formattedEvent:(NGLogEvent *)_event {
- return [NSString stringWithFormat:@"[%@] %@",
- [self localizedNameOfLogLevel:[_event level]],
- [_event message]];
+ NSMutableString *fe;
+ NSString *lvl;
+
+ lvl = [self localizedNameOfLogLevel:[_event level]];
+ fe = [NSMutableString stringWithCapacity:128];
+ if(lvl) {
+ [fe appendString:@"["];
+ [fe appendString:lvl];
+ [fe appendString:@"] "];
+ }
+ [fe appendString:[_event message]];
+ return fe;
}
- (NSString *)localizedNameOfLogLevel:(NGLogLevel)_level {
NSString *name;
switch (_level) {
- case NGLogLevelDebug:
- name = @"DEBUG";
- break;
- case NGLogLevelInfo:
- name = @"INFO";
- break;
case NGLogLevelWarn:
name = @"WARN";
break;
name = @"FATAL";
break;
default:
- name = @"";
+ name = nil;
break;
}
return name;
@implementation NGLogEvent
-static Class DateClass = Nil;
+static Class NSDateClass = Nil;
+ (void)initialize {
- DateClass = [NSDate class];
+ NSDateClass = [NSDate class];
}
- (id)initWithLevel:(NGLogLevel)_level message:(NSString *)_msg {
- if((self = [super init])) {
- self->date = [DateClass timeIntervalSinceReferenceDate];
- self->level = _level;
- self->msg = [_msg copy];
+ self = [super init];
+ if(self) {
+ self->date = [NSDateClass timeIntervalSinceReferenceDate];
+ self->level = _level;
+ self->msg = [_msg copy];
}
return self;
}
- (void)dealloc {
- [self->msg release];
+ [self->msg release];
[super dealloc];
}
}
- (NSDate *)date {
- return [DateClass dateWithTimeIntervalSinceReferenceDate:self->date];
+ return [NSDateClass dateWithTimeIntervalSinceReferenceDate:self->date];
}
@end /* NGLogEvent */
#include "NGLogEvent.h"
#include "NGLogAppender.h"
+@interface NGLogger (PrivateAPI)
+- (void)logLevel:(NGLogLevel)_level message:(NSString *)_msg;
+- (void)logLevel:(NGLogLevel)_level withFormat:(NSString *)_fmt, ...;
+@end
+
@implementation NGLogger
static Class NSStringClass = Nil;
+ (void)initialize {
static BOOL didInit = NO;
- if(didInit)
+ if (didInit)
return;
- didInit = YES;
+ didInit = YES;
NSStringClass = [NSString class];
}
}
- (id)initWithLogLevel:(NGLogLevel)_level {
- if ((self = [super init])) {
+ self = [super init];
+ if (self) {
NSUserDefaults *ud;
- NSString *appenderClassName;
-
+ NSString *appenderClassName;
+
[self setLogLevel:_level];
// TODO: remove this as soon as we have a config
- ud = [NSUserDefaults standardUserDefaults];
+ ud = [NSUserDefaults standardUserDefaults];
appenderClassName = [ud stringForKey:@"NGLogDefaultAppenderClass"];
if (appenderClassName == nil)
appenderClassName = @"NGLogConsoleAppender";
- self->_appender = [[NSClassFromString(appenderClassName) alloc] init];
+ self->_appender = [[NSClassFromString(appenderClassName) alloc] init];
}
return self;
}
/* logging */
+- (void)debugWithFormat:(NSString *)_fmt arguments:(va_list)_va {
+ NSString *msg;
+
+ if (self->logLevel < NGLogLevelDebug) return;
+
+ msg = [[NSStringClass alloc] initWithFormat:_fmt arguments:_va];
+ [self logLevel:NGLogLevelDebug message:msg];
+ [msg release];
+}
+
+- (void)logWithFormat:(NSString *)_fmt arguments:(va_list)_va {
+ NSString *msg;
+
+ if (self->logLevel < NGLogLevelInfo) return;
+
+ msg = [[NSStringClass alloc] initWithFormat:_fmt arguments:_va];
+ [self logLevel:NGLogLevelInfo message:msg];
+ [msg release];
+}
+
+- (void)warnWithFormat:(NSString *)_fmt arguments:(va_list)_va {
+ NSString *msg;
+
+ if (self->logLevel < NGLogLevelWarn) return;
+
+ msg = [[NSStringClass alloc] initWithFormat:_fmt arguments:_va];
+ [self logLevel:NGLogLevelWarn message:msg];
+ [msg release];
+}
+
+- (void)errorWithFormat:(NSString *)_fmt arguments:(va_list)_va {
+ NSString *msg;
+
+ if (self->logLevel < NGLogLevelError) return;
+
+ msg = [[NSStringClass alloc] initWithFormat:_fmt arguments:_va];
+ [self logLevel:NGLogLevelError message:msg];
+ [msg release];
+}
+
+- (void)fatalWithFormat:(NSString *)_fmt arguments:(va_list)_va {
+ NSString *msg;
+
+ if (self->logLevel < NGLogLevelFatal) return;
+
+ msg = [[NSStringClass alloc] initWithFormat:_fmt arguments:_va];
+ [self logLevel:NGLogLevelFatal message:msg];
+ [msg release];
+}
+
- (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)
- return;
-
- va_start(va, _fmt);
- msg = [[NSStringClass alloc] initWithFormat:_fmt arguments:va];
- va_end(va);
- [self logLevel:_level message:msg];
- [msg release];
-}
-
/* log conditions */
-- (BOOL)isLogDebugEnabled {
+- (BOOL)isDebuggingEnabled {
return self->logLevel >= NGLogLevelDebug;
}
- (BOOL)isLogInfoEnabled {
*/
#include "NGLoggerManager.h"
-#include "NSObject+ExtendedLogging.h"
+#include "NGLogLevel.h"
#include "NGLogger.h"
#include "common.h"
-@interface NGLoggerManager (PrivateAPI)
-- (NGLogLevel)_logLevelForString:(NSString *)_defaultValue;
-@end
-
@implementation NGLoggerManager
static NGLoggerManager *sharedInstance;
logger = [self->loggerMap objectForKey:_defaultKey];
if (!logger) {
NSUserDefaults *ud;
- NSString *levelId;
- NGLogLevel level;
- ud = [NSUserDefaults standardUserDefaults];
- levelId = [[ud stringForKey:_defaultKey] uppercaseString];
- level = [self _logLevelForString:levelId];
- if (level == NGLogLevelOff) {
+ ud = [NSUserDefaults standardUserDefaults];
+ if (![ud boolForKey:_defaultKey]) {
[self->loggerMap setObject:sharedNull forKey:_defaultKey];
logger = sharedNull;
}
else {
- logger = [[NGLogger alloc] initWithLogLevel:level];
+ logger = [[NGLogger alloc] initWithLogLevel:NGLogLevelDebug];
[self->loggerMap setObject:logger forKey:_defaultKey];
[logger release];
}
return [self loggerForFacilityNamed:name];
}
-
-/* Private */
-
-- (NGLogLevel)_logLevelForString:(NSString *)_defaultValue {
- if ([_defaultValue length] == 0 || [_defaultValue isEqualToString:@"NO"])
- return NGLogLevelOff;
-
- if ([_defaultValue isEqualToString:@"YES"] ||
- [_defaultValue isEqualToString:@"DEBUG"])
- return NGLogLevelDebug;
-
- if ([_defaultValue isEqualToString:@"INFO"])
- return NGLogLevelInfo;
- if ([_defaultValue isEqualToString:@"WARN"])
- return NGLogLevelWarn;
- if ([_defaultValue isEqualToString:@"ERROR"])
- return NGLogLevelError;
- if ([_defaultValue isEqualToString:@"FATAL"])
- return NGLogLevelFatal;
-
- return NGLogLevelAll;
-}
-
@end /* NGLoggerManager */
+++ /dev/null
-/*
- 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)
-
-+ (id)logger {
- static id sharedLogger = nil;
-
- if (sharedLogger == nil) {
- NGLoggerManager *lm;
-
- lm = [NGLoggerManager defaultLoggerManager];
- sharedLogger = [lm loggerForDefaultKey:@"NGDefaultLogLevel"];
- if (!sharedLogger) {
- sharedLogger = [lm loggerForFacilityNamed:@"root"];
- [sharedLogger setLogLevel:NGLogLevelInfo];
- }
- }
- return sharedLogger;
-}
-
-- (id)logger {
- return [[self class] logger];
-}
-
-/* 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);
- [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);
- [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);
- [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);
- [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);
- [logger logLevel:NGLogLevelFatal message:msg];
- [msg release];
-}
-
-- (void)logLevel:(NGLogLevel)_level message:(NSString *)_msg {
- [[self logger] logLevel:_level message:_msg];
-}
-
-- (void)logLevel:(NGLogLevel)_level withFormat:(NSString *)_fmt, ... {
- NSString *msg;
- va_list va;
-
- va_start(va, _fmt);
- msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
- va_end(va);
- [[self logger] logLevel:_level withFormat:msg];
- [msg release];
-}
-
-/* log conditions (do not use, slow ...) */
-
-- (BOOL)isLogDebugEnabled {
- return [[self logger] isLogDebugEnabled];
-}
-
-- (BOOL)isLogInfoEnabled {
- return [[self logger] isLogInfoEnabled];
-}
-
-- (BOOL)isLogWarnEnabled {
- return [[self logger] isLogWarnEnabled];
-}
-
-- (BOOL)isLogErrorEnabled {
- return [[self logger] isLogErrorEnabled];
-}
-
-- (BOOL)isLogFatalEnabled {
- return [[self logger] isLogFatalEnabled];
-}
-
-@end /* NSObject(NGExtendedLogging) */
# version
-SUBMINOR_VERSION:=133
+SUBMINOR_VERSION:=134
# v4.3.115 requires libFoundation v1.0.59
# v4.2.72 requires libEOControl v4.2.39