2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OGo
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
24 #import "NGLogSyslogAppender.h"
25 #import "NGLogEvent.h"
30 @interface NGLogSyslogAppender (PrivateAPI)
31 - (int)syslogPriorityForLogLevel:(NGLogLevel)_level;
34 @implementation NGLogSyslogAppender
37 static NSString *defaultSyslogIdentifier = nil;
42 static BOOL isInitialized = NO;
47 ud = [NSUserDefaults standardUserDefaults];
48 defaultSyslogIdentifier =
49 [[ud stringForKey:@"NGLogSyslogIdentifier"] retain];
54 + (id)sharedAppender {
55 static id sharedAppender = nil;
56 if(sharedAppender == nil) {
57 sharedAppender = [[self alloc] init];
59 return sharedAppender;
63 return [self initWithIdentifier:defaultSyslogIdentifier];
66 - (id)initWithIdentifier:(NSString *)_ident {
67 if((self = [super init])) {
68 #warning ** default flags?
69 openlog([_ident cString], LOG_PID | LOG_NDELAY, LOG_USER);
79 - (void)appendLogEvent:(NGLogEvent *)_event {
82 level = [self syslogPriorityForLogLevel:[_event level]];
83 syslog(level, [[_event message] cString]);
86 - (int)syslogLevelForLogLevel:(NGLogLevel)_level {
102 case NGLogLevelFatal:
103 level = LOG_ALERT; // LOG_EMERG is broadcast to all users...