summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1bfce80)
+2004-11-15 Marcus Mueller <znek@mulle-kybernetik.com>
+
+ * v4.5.87
+
+ * WOCoreApplication.m: needed to define a private +logger to enable
+ proper logging in class methods.
+
+ * WOHttpAdaptor/common.h: add new logging API to common includes
+
+ * WOHttpAdaptor/WOHttpAdaptor.m: rewrote logging to use new logging
+ API. Added an own (conditional) logger for performance logging.
+
2004-11-13 Helge Hess <helge.hess@opengroupware.org>
* WOApplication.m: changed wrapper-missing-log from warn to debug
2004-11-13 Helge Hess <helge.hess@opengroupware.org>
* WOApplication.m: changed wrapper-missing-log from warn to debug
# v4.5.84 required libNGExtensions v4.5.127
# v4.3.42 requires libNGExtensions v4.3.116
# v4.5.84 required libNGExtensions v4.5.127
# v4.3.42 requires libNGExtensions v4.3.116
@interface WOCoreApplication(PrivateMethods)
+ (void)_initDefaults;
@interface WOCoreApplication(PrivateMethods)
+ (void)_initDefaults;
- (NSDictionary *)memoryStatistics;
- (WOResponse *)handleException:(NSException *)_exc;
@end
- (NSDictionary *)memoryStatistics;
- (WOResponse *)handleException:(NSException *)_exc;
@end
static id sharedLogger = nil;
if(sharedLogger == nil) {
sharedLogger = [[NGLogger alloc] initWithLogLevel:NGLogLevelDebug];
static id sharedLogger = nil;
if(sharedLogger == nil) {
sharedLogger = [[NGLogger alloc] initWithLogLevel:NGLogLevelDebug];
+- (id)logger {
+ return [[self class] logger];
+}
+
/* signals */
- (void)processHupSignal:(int)_signal {
/* signals */
- (void)processHupSignal:(int)_signal {
# warning extensive pools are enabled ...
#endif
# warning extensive pools are enabled ...
#endif
-static BOOL HTTP_PERFLOG = NO;
-
#include "WOHttpAdaptor.h"
#include "WORecordRequestStream.h"
#include "WOHttpTransaction.h"
#include "WOHttpAdaptor.h"
#include "WORecordRequestStream.h"
#include "WOHttpTransaction.h"
-@interface WOHttpAdaptor(PrivateMethods2)
-
-- (void)logWithFormat:(NSString *)_format, ...;
-
-@end
-
@interface WOCoreApplication(Port)
- (NSNumber *)port;
@end
@implementation WOHttpAdaptor
@interface WOCoreApplication(Port)
- (NSNumber *)port;
@end
@implementation WOHttpAdaptor
+static NGLogger *perfLogger = nil;
static BOOL WOHttpAdaptor_LogStream = NO;
static BOOL WOContactSNS = NO;
static BOOL WOCoreOnHTTPAdaptorException = NO;
static BOOL WOHttpAdaptor_LogStream = NO;
static BOOL WOContactSNS = NO;
static BOOL WOCoreOnHTTPAdaptorException = NO;
-static NSString *WOPort = nil;
-static int WOHttpAdaptorSendTimeout = 10;
-static int WOHttpAdaptorReceiveTimeout = 10;
-static id allow = nil;
-static BOOL debugOn = NO;
+static NSString *WOPort = nil;
+static int WOHttpAdaptorSendTimeout = 10;
+static int WOHttpAdaptorReceiveTimeout = 10;
+static id allow = nil;
+static BOOL debugOn = NO;
+ (BOOL)optionLogStream {
return WOHttpAdaptor_LogStream;
}
+ (BOOL)optionLogPerf {
+ (BOOL)optionLogStream {
return WOHttpAdaptor_LogStream;
}
+ (BOOL)optionLogPerf {
+ return perfLogger != nil ? YES : NO;
}
+ (int)version {
return [super version] + 1 /* v2 */;
}
+ (void)initialize {
}
+ (int)version {
return [super version] + 1 /* v2 */;
}
+ (void)initialize {
- NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
- static BOOL didInit = NO;
+ NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
+ NGLoggerManager *um = [NGLoggerManager defaultLoggerManager];
+ static BOOL didInit = NO;
+
if (didInit) return;
didInit = YES;
if (didInit) return;
didInit = YES;
NSStringFromClass([self superclass]), [super version]);
WOHttpAdaptor_LogStream = [ud boolForKey:@"WOHttpAdaptor_LogStream"];
NSStringFromClass([self superclass]), [super version]);
WOHttpAdaptor_LogStream = [ud boolForKey:@"WOHttpAdaptor_LogStream"];
- HTTP_PERFLOG = [[ud objectForKey:@"WOProfileHttpAdaptor"] boolValue];
+ perfLogger = [um loggerForDefaultKey:@"WOProfileHttpAdaptor"];
// TODO: those two should be queried on demand to allow different defaults
WOPort = [[ud stringForKey:@"WOPort"] copy];
// TODO: those two should be queried on demand to allow different defaults
WOPort = [[ud stringForKey:@"WOPort"] copy];
}
if (WOCoreOnHTTPAdaptorException)
}
if (WOCoreOnHTTPAdaptorException)
- NSLog(@"WARNING: will dump core on HTTP adaptor exception!");
+ [self logWarnWithFormat:@"will dump core on HTTP adaptor exception!"];
}
- (id)autoBindAddress {
}
- (id)autoBindAddress {
self->address = [self->address retain];
if (self->address == nil) {
self->address = [self->address retain];
if (self->address == nil) {
- [_application logWithFormat:
+ [_application logErrorWithFormat:
@"got no address for HTTP server (using arg '%@')", arg];
[self release];
return nil;
}
if (!WOContactSNS) {
@"got no address for HTTP server (using arg '%@')", arg];
[self release];
return nil;
}
if (!WOContactSNS) {
- [_application logWithFormat:@"%@ listening on address %@",
+ [_application logInfoWithFormat:@"%@ listening on address %@",
NSStringFromClass([self class]),
[(id)self->address stringValue]];
}
NSStringFromClass([self class]),
[(id)self->address stringValue]];
}
/* events */
- (void)handleSIGPIPE:(int)_signal {
/* events */
- (void)handleSIGPIPE:(int)_signal {
- [self logWithFormat:@"caught SIGPIPE !"];
+ [self logWarnWithFormat:@"caught SIGPIPE !"];
}
- (void)registerForEvents {
}
- (void)registerForEvents {
self->address = [[self->socket localAddress] retain];
self->address = [[self->socket localAddress] retain];
- [self logWithFormat:@"bound to kernel assigned address %@: %@",
+ [self logInfoWithFormat:@"bound to kernel assigned address %@: %@",
self->address, self->socket];
}
}
self->address, self->socket];
}
}
-- (void)logWithFormat:(NSString *)_format, ... {
- NSString *value = nil;
- va_list ap;
-
- va_start(ap, _format);
- value = [[NSString alloc] initWithFormat:_format arguments:ap];
- va_end(ap);
-
- NSLog(@"WOHttpAdaptor: %@", value);
- [value release]; value = nil;
+- (id)logger {
+ static id sharedLogger = nil;
+ if(sharedLogger == nil) {
+ sharedLogger = [[NGLogger alloc] initWithLogLevel:NGLogLevelDebug];
+ }
+ return sharedLogger;
}
/* run-loop */
- (void)_serverCatched:(NSException *)_exc {
}
/* run-loop */
- (void)_serverCatched:(NSException *)_exc {
- [self logWithFormat:@"http server caught: %@", _exc];
+ [self logErrorWithFormat:@"http server caught: %@", _exc];
if (WOCoreOnHTTPAdaptorException) abort();
}
if (WOCoreOnHTTPAdaptorException) abort();
}
WOHttpTransaction *tx;
if (_socket == nil) {
WOHttpTransaction *tx;
if (_socket == nil) {
- [self logWithFormat:@"got no socket for transaction ??"];
+ [self logErrorWithFormat:@"got no socket for transaction ??"];
*(&t) = [[NSDate date] timeIntervalSince1970];
[self->lock lock];
*(&t) = [[NSDate date] timeIntervalSince1970];
[self->lock lock];
self->activeThreadCount--;
[self->lock unlock];
self->activeThreadCount--;
[self->lock unlock];
t = [[NSDate date] timeIntervalSince1970] - t;
t = [[NSDate date] timeIntervalSince1970] - t;
- [self logWithFormat:@"handling of request took %4.3fs.",
- t < 0.0 ? -1.0 : t];
+ [perfLogger logInfoWithFormat:@"handling of request took %4.3fs.",
+ t < 0.0 ? -1.0 : t];
id<NGSocketAddress> remote;
if ((remote = [_connection remoteAddress]) == nil) {
id<NGSocketAddress> remote;
if ((remote = [_connection remoteAddress]) == nil) {
+ [self logErrorWithFormat:
@"missing remote address for connection: %@",
_connection];
return nil;
@"missing remote address for connection: %@",
_connection];
return nil;
- [self logWithFormat:@"ACCESS DENIED: %@", ipAddr];
+ [self logErrorWithFormat:@"ACCESS DENIED: %@", ipAddr];
[NSThread detachNewThreadSelector:@selector(_handleAcceptedConnection:)
toTarget:self
withObject:[connection retain]];
[NSThread detachNewThreadSelector:@selector(_handleAcceptedConnection:)
toTarget:self
withObject:[connection retain]];
- [self logWithFormat:@"detached new thread for request."];
+ [self logInfoWithFormat:@"detached new thread for request."];
//[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:10]];
}
connection = nil;
//[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:10]];
}
connection = nil;
[self->socket close];
[self->socket release]; self->socket = nil;
}
[self->socket close];
[self->socket release]; self->socket = nil;
}
- NSLog(@"adaptor stops application: %@ ...", self->application);
+ [self logInfoWithFormat:@"adaptor stops application: %@ ...",
+ self->application];
#import <Foundation/Foundation.h>
#include <NGExtensions/NGExtensions.h>
#import <Foundation/Foundation.h>
#include <NGExtensions/NGExtensions.h>
+#include <NGExtensions/NGLogging.h>
#include <NGStreams/NGStreams.h>
#include <NGStreams/NGNet.h>
#include <NGStreams/NGStreams.h>
#include <NGStreams/NGNet.h>