From: znek Date: Thu, 27 May 2004 14:00:27 +0000 (+0000) Subject: syslog appender, notes/readme updated X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b3ebc67f47532ba54a89208a8c52b4349634573;p=scalable-opengroupware.org syslog appender, notes/readme updated git-svn-id: http://svn.opengroupware.org/SOGo/trunk@9 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/WebUI/ChangeLog b/WebUI/ChangeLog index 07ff8b46..dec9a562 100644 --- a/WebUI/ChangeLog +++ b/WebUI/ChangeLog @@ -1,3 +1,9 @@ +2004-05-27 Marcus Mueller + + * README, NOTES: updated + + * NGExtensions/NGLogging/ChangeLog: created + 2004-05-26 Marcus Mueller * ChangeLog: created diff --git a/WebUI/NGExtensions/NGLogging/ChangeLog b/WebUI/NGExtensions/NGLogging/ChangeLog new file mode 100644 index 00000000..ef2c49cb --- /dev/null +++ b/WebUI/NGExtensions/NGLogging/ChangeLog @@ -0,0 +1,5 @@ +2004-05-27 Marcus Mueller + + * NGLogSyslogAppender.[hm]: syslog appender, untested. + + * ChangeLog: created diff --git a/WebUI/NGExtensions/NGLogging/NGLogSyslogAppender.h b/WebUI/NGExtensions/NGLogging/NGLogSyslogAppender.h new file mode 100644 index 00000000..e7253b82 --- /dev/null +++ b/WebUI/NGExtensions/NGLogging/NGLogSyslogAppender.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2000-2004 SKYRIX Software AG + + This file is part of OGo + + 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. +*/ +// $Id$ + + +#ifndef __NGLogSyslogAppender_H_ +#define __NGLogSyslogAppender_H_ + + +#import "NGLogAppender.h" + + +@interface NGLogSyslogAppender : NGLogAppender +{ + +} + ++ (id)sharedAppender; + +/* provide syslog identifier */ +- (id)initWithIdentifier:(NSString *)_ident; + +@end + +#endif /* __NGLogSyslogAppender_H_ */ diff --git a/WebUI/NGExtensions/NGLogging/NGLogSyslogAppender.m b/WebUI/NGExtensions/NGLogging/NGLogSyslogAppender.m new file mode 100644 index 00000000..f9b7dc31 --- /dev/null +++ b/WebUI/NGExtensions/NGLogging/NGLogSyslogAppender.m @@ -0,0 +1,112 @@ +/* + Copyright (C) 2000-2004 SKYRIX Software AG + + This file is part of OGo + + 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. +*/ +// $Id$ + + +#import "NGLogSyslogAppender.h" +#import "NGLogEvent.h" +#include +#include + + +@interface NGLogSyslogAppender (PrivateAPI) +- (int)syslogPriorityForLogLevel:(NGLogLevel)_level; +@end + +@implementation NGLogSyslogAppender + + +static NSString *defaultSyslogIdentifier = nil; + + ++ (void)initialize { + NSUserDefaults *ud; + static BOOL isInitialized = NO; + + if(isInitialized) + return; + + ud = [NSUserDefaults standardUserDefaults]; + defaultSyslogIdentifier = + [[ud stringForKey:@"NGLogSyslogIdentifier"] retain]; + + isInitialized = YES; +} + ++ (id)sharedAppender { + static id sharedAppender = nil; + if(sharedAppender == nil) { + sharedAppender = [[self alloc] init]; + } + return sharedAppender; +} + +- (id)init { + return [self initWithIdentifier:defaultSyslogIdentifier]; +} + +- (id)initWithIdentifier:(NSString *)_ident { + if((self = [super init])) { + #warning ** default flags? + openlog([_ident cString], LOG_PID | LOG_NDELAY, LOG_USER); + } + return self; +} + +- (void)dealloc { + closelog(); + [super dealloc]; +} + +- (void)appendLogEvent:(NGLogEvent *)_event { + int level; + + level = [self syslogPriorityForLogLevel:[_event level]]; + syslog(level, [[_event message] cString]); +} + +- (int)syslogLevelForLogLevel:(NGLogLevel)_level { + int level; + + switch (_level) { + case NGLogLevelDebug: + level = LOG_DEBUG; + break; + case NGLogLevelInfo: + level = LOG_INFO; + break; + case NGLogLevelWarn: + level = LOG_WARNING; + break; + case NGLogLevelError: + level = LOG_ERR; + break; + case NGLogLevelFatal: + level = LOG_ALERT; // LOG_EMERG is broadcast to all users... + break; + default: + level = LOG_NOTICE; + break; + } + return level; +} + +@end diff --git a/WebUI/NOTES b/WebUI/NOTES index e69de29b..e42d0050 100644 --- a/WebUI/NOTES +++ b/WebUI/NOTES @@ -0,0 +1,14 @@ +$Id$ + +- NGExtensions + - Stuff I believe might be useful for later addition to NGExtensions framework + + - NGLogging + - Had a look at log4cocoa, appeared to be too bloated (they mimic all of + log4j which doesn't really make sense in Objective-C). + - NGLogConsoleAppender is the only appender currently available, it's + hardcoded in NGLogger as default. This should change as soon as we have + 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 diff --git a/WebUI/README b/WebUI/README index 591cb493..2c79e708 100644 --- a/WebUI/README +++ b/WebUI/README @@ -1,16 +1,24 @@ $Id$ +WebUI + Part of SOGo + Copyright (C) 2000-2004 SKYRIX Software AG - http://www.skyrix.com/ -Xcode notes: +Subprojects +=========== + +- NGExtensions + - NGLogging + + +UserDefaults ============ + Default | Type | Example Value + ============================================================= + NGLogSyslogIdentifier | String | WebUI + + -Rapid Development -================= -In order for "Rapid Development" to work properly you need to open -Xcode's "Project" menu and select "Edit active executable" -(Apple-Option-X). In the following dialog navigate to the "Runtime" -section and select the "Project Directory" as the working directory -when launching the executable. diff --git a/WebUI/WebUI.xcode/project.pbxproj b/WebUI/WebUI.xcode/project.pbxproj index ac93e12f..bc136fe6 100644 --- a/WebUI/WebUI.xcode/project.pbxproj +++ b/WebUI/WebUI.xcode/project.pbxproj @@ -279,6 +279,7 @@ ADC15A4F0664E25B0063754B, ADC15A560664E33A0063754B, AD1967250665E52400E19038, + AD0618D0066610A200AC467F, ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -297,6 +298,7 @@ ADA38B8205DD238A00C820AA, AD95AEBA0664BC6700FCB211, AD95AEBC0664BC7B00FCB211, + AD0618D50666121C00AC467F, ); isa = PBXResourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -319,6 +321,7 @@ ADC15A500664E25B0063754B, ADC15A570664E33A0063754B, AD1967260665E52400E19038, + AD0618D1066610A200AC467F, ); isa = PBXSourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -366,6 +369,50 @@ //AD2 //AD3 //AD4 + AD0618CE066610A200AC467F = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + path = NGLogSyslogAppender.h; + refType = 4; + sourceTree = ""; + }; + AD0618CF066610A200AC467F = { + fileEncoding = 4; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.objc; + path = NGLogSyslogAppender.m; + refType = 4; + sourceTree = ""; + }; + AD0618D0066610A200AC467F = { + fileRef = AD0618CE066610A200AC467F; + isa = PBXBuildFile; + settings = { + }; + }; + AD0618D1066610A200AC467F = { + fileRef = AD0618CF066610A200AC467F; + isa = PBXBuildFile; + settings = { + }; + }; + AD0618D40666121C00AC467F = { + explicitFileType = text; + fileEncoding = 4; + isa = PBXFileReference; + path = ChangeLog; + refType = 4; + sourceTree = ""; + tabWidth = 4; + usesTabs = 1; + }; + AD0618D50666121C00AC467F = { + fileRef = AD0618D40666121C00AC467F; + isa = PBXBuildFile; + settings = { + }; + }; AD0ACCDE062732BD0054A820 = { children = ( AD0ACCDF062733370054A820, @@ -553,6 +600,7 @@ path = ChangeLog; refType = 4; sourceTree = ""; + tabWidth = 4; usesTabs = 1; }; AD95AEBC0664BC7B00FCB211 = { @@ -767,6 +815,7 @@ ADC15A530664E3280063754B = { children = ( AD1967660665FE6800E19038, + AD0618D40666121C00AC467F, ADC15A450664DA320063754B, ADC15A410664D1D90063754B, ADC15A420664D1D90063754B, @@ -778,6 +827,8 @@ ADC15A4E0664E25B0063754B, AD1967230665E52400E19038, AD1967240665E52400E19038, + AD0618CE066610A200AC467F, + AD0618CF066610A200AC467F, ); isa = PBXGroup; name = Logging;