From: znek Date: Thu, 27 May 2004 15:39:32 +0000 (+0000) Subject: syslog appender -> tested X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9c1d5c56991c0be9673c5bb83a755b515c1fdd88;p=scalable-opengroupware.org syslog appender -> tested git-svn-id: http://svn.opengroupware.org/SOGo/trunk@10 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/WebUI/ChangeLog b/WebUI/ChangeLog index dec9a562..b45b24dd 100644 --- a/WebUI/ChangeLog +++ b/WebUI/ChangeLog @@ -1,3 +1,7 @@ +2004-05-27 Marcus Mueller + + * README: updated + 2004-05-27 Marcus Mueller * README, NOTES: updated diff --git a/WebUI/NGExtensions/NGLogging/ChangeLog b/WebUI/NGExtensions/NGLogging/ChangeLog index ef2c49cb..770975e0 100644 --- a/WebUI/NGExtensions/NGLogging/ChangeLog +++ b/WebUI/NGExtensions/NGLogging/ChangeLog @@ -1,3 +1,15 @@ +2004-05-27 Marcus Mueller + + * NGLogAppender.[hm]: introduced -formattedEvent:, currently not + configurable. + + * NGLogSyslogAppender.m: works as expected now. + + * NGLogger.m: uses new default (see README) to select the default + appender. Not optimal, but sufficient. + + * NGLogConsoleAppender.m: changed to use -formattedEvent: now. + 2004-05-27 Marcus Mueller * NGLogSyslogAppender.[hm]: syslog appender, untested. diff --git a/WebUI/NGExtensions/NGLogging/NGLogAppender.h b/WebUI/NGExtensions/NGLogging/NGLogAppender.h index bf00ca94..fabab54a 100644 --- a/WebUI/NGExtensions/NGLogging/NGLogAppender.h +++ b/WebUI/NGExtensions/NGLogging/NGLogAppender.h @@ -42,6 +42,7 @@ /* subclass responsibility */ - (void)appendLogEvent:(NGLogEvent *)_event; +- (NSString *)formattedEvent:(NGLogEvent *)_event; - (NSString *)localizedNameOfLogLevel:(NGLogLevel)_level; diff --git a/WebUI/NGExtensions/NGLogging/NGLogAppender.m b/WebUI/NGExtensions/NGLogging/NGLogAppender.m index e8f2c18f..3743c843 100644 --- a/WebUI/NGExtensions/NGLogging/NGLogAppender.m +++ b/WebUI/NGExtensions/NGLogging/NGLogAppender.m @@ -22,6 +22,7 @@ #import "NGLogAppender.h" +#import "NGLogEvent.h" @implementation NGLogAppender @@ -30,6 +31,12 @@ [self subclassResponsibility:_cmd]; } +- (NSString *)formattedEvent:(NGLogEvent *)_event { + return [NSString stringWithFormat:@"[%@] %@", + [self localizedNameOfLogLevel:[_event level]], + [_event message]]; +} + - (NSString *)localizedNameOfLogLevel:(NGLogLevel)_level { NSString *name; diff --git a/WebUI/NGExtensions/NGLogging/NGLogConsoleAppender.m b/WebUI/NGExtensions/NGLogging/NGLogConsoleAppender.m index 53eb3df6..d9a53c46 100644 --- a/WebUI/NGExtensions/NGLogging/NGLogConsoleAppender.m +++ b/WebUI/NGExtensions/NGLogging/NGLogConsoleAppender.m @@ -28,7 +28,7 @@ @implementation NGLogConsoleAppender - (void)appendLogEvent:(NGLogEvent *)_event { - NSLog(@"%@: %@", [self localizedNameOfLogLevel:[_event level]], [_event message]); + NSLog([self formattedEvent:_event]); } @end diff --git a/WebUI/NGExtensions/NGLogging/NGLogSyslogAppender.m b/WebUI/NGExtensions/NGLogging/NGLogSyslogAppender.m index f9b7dc31..856b4754 100644 --- a/WebUI/NGExtensions/NGLogging/NGLogSyslogAppender.m +++ b/WebUI/NGExtensions/NGLogging/NGLogSyslogAppender.m @@ -28,7 +28,7 @@ @interface NGLogSyslogAppender (PrivateAPI) -- (int)syslogPriorityForLogLevel:(NGLogLevel)_level; +- (int)syslogLevelForLogLevel:(NGLogLevel)_level; @end @implementation NGLogSyslogAppender @@ -77,10 +77,12 @@ static NSString *defaultSyslogIdentifier = nil; } - (void)appendLogEvent:(NGLogEvent *)_event { + NSString *formattedMsg; int level; - - level = [self syslogPriorityForLogLevel:[_event level]]; - syslog(level, [[_event message] cString]); + + formattedMsg = [self formattedEvent:_event]; + level = [self syslogLevelForLogLevel:[_event level]]; + syslog(level, [formattedMsg cString]); } - (int)syslogLevelForLogLevel:(NGLogLevel)_level { diff --git a/WebUI/NGExtensions/NGLogging/NGLogger.m b/WebUI/NGExtensions/NGLogging/NGLogger.m index 9f9d4853..52a08de1 100644 --- a/WebUI/NGExtensions/NGLogging/NGLogger.m +++ b/WebUI/NGExtensions/NGLogging/NGLogger.m @@ -26,7 +26,6 @@ #include "common.h" #include "NGLogEvent.h" #include "NGLogAppender.h" -#include "NGLogConsoleAppender.h" @implementation NGLogger @@ -38,9 +37,17 @@ - (id)initWithLogLevel:(NGLogLevel)_level { if((self = [super init])) { + NSUserDefaults *ud; + NSString *appenderClassName; + [self setLogLevel:_level]; + #warning ** remove this as soon as we have a config - self->_appender = [[NGLogConsoleAppender alloc] init]; + ud = [NSUserDefaults standardUserDefaults]; + appenderClassName = [ud stringForKey:@"NGLogDefaultAppenderClass"]; + if(appenderClassName == nil) + appenderClassName = @"NGLogConsoleAppender"; + self->_appender = [[NSClassFromString(appenderClassName) alloc] init]; } return self; } diff --git a/WebUI/NOTES b/WebUI/NOTES index e42d0050..16dc5b80 100644 --- a/WebUI/NOTES +++ b/WebUI/NOTES @@ -11,4 +11,5 @@ $Id$ a config for that purpose. Logging is low priority, so we don't need to do that too soon. - Syslog appender might be useful for the ministry. Syslog provides its own - buffering, so syslog appender should be straight forward. \ No newline at end of file + buffering, so syslog appender should be straight forward. Current + implementation makes some fix assumptions (log facility). \ No newline at end of file diff --git a/WebUI/README b/WebUI/README index 2c79e708..c5beb54d 100644 --- a/WebUI/README +++ b/WebUI/README @@ -15,10 +15,10 @@ Subprojects UserDefaults ============ - Default | Type | Example Value - ============================================================= - NGLogSyslogIdentifier | String | WebUI - + Default | Type | Example Value + ============================================================== + NGLogSyslogIdentifier | String | WebUI + NGLogDefaultAppenderClass| String | NGLogConsoleAppender