2 Copyright (C) 2004-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE 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 SOPE 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 SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "NGLogAppender.h"
23 #include "NGLogLevel.h"
24 #include "NGLogEvent.h"
25 #include "NGLogEventFormatter.h"
28 @implementation NGLogAppender
30 static NSString *defaultAppenderClassName = nil;
33 static BOOL didInit = NO;
39 ud = [NSUserDefaults standardUserDefaults];
40 defaultAppenderClassName =
41 [[ud stringForKey:@"NGLogDefaultAppenderClass"] retain];
42 if (defaultAppenderClassName == nil)
43 defaultAppenderClassName = @"NGLogStdoutAppender";
46 + (id)logAppenderFromConfig:(NSDictionary *)_config {
51 className = [_config objectForKey:@"Class"];
53 className = defaultAppenderClassName;
54 clazz = NSClassFromString(className);
56 NSLog(@"ERROR: can't instantiate appender class named '%@'",
60 appender = [[[clazz alloc] initWithConfig:_config] autorelease];
64 - (id)initWithConfig:(NSDictionary *)_config {
67 NSDictionary *formatterConfig;
69 formatterConfig = [_config objectForKey:@"Formatter"];
71 [[NGLogEventFormatter logEventFormatterFromConfig:formatterConfig]
77 - (void)appendLogEvent:(NGLogEvent *)_event {
78 #if LIB_FOUNDATION_LIBRARY
79 [self subclassResponsibility:_cmd];
81 NSLog(@"ERROR(%s): method should be implemented by subclass!",
88 - (NSString *)formattedEvent:(NGLogEvent *)_event {
89 return [self->formatter formattedEvent:_event];
92 @end /* NGLogAppender */