]> err.no Git - sope/blob - sope-core/NGExtensions/NGLogging.subproj/NGLogAppender.m
86211367e3a07715e5dd19b4328b3e1d9a35d1ab
[sope] / sope-core / NGExtensions / NGLogging.subproj / NGLogAppender.m
1 /*
2  Copyright (C) 2000-2004 SKYRIX Software AG
3  
4  This file is part of OpenGroupware.org.
5  
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
9  later version.
10  
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.
15  
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
19  02111-1307, USA.
20  */
21
22 #include "NGLogAppender.h"
23 #include "NSObject+ExtendedLogging.h"
24 #include "NGLogEvent.h"
25
26 @implementation NGLogAppender
27
28 - (void)appendLogEvent:(NGLogEvent *)_event {
29   [self subclassResponsibility:_cmd];
30 }
31
32 - (NSString *)formattedEvent:(NGLogEvent *)_event {
33   return [NSString stringWithFormat:@"[%@] %@",
34     [self localizedNameOfLogLevel:[_event level]],
35     [_event message]];
36 }
37
38 - (NSString *)localizedNameOfLogLevel:(NGLogLevel)_level {
39   NSString *name;
40   
41   switch (_level) {
42     case NGLogLevelDebug:
43       name = @"DEBUG";
44       break;
45     case NGLogLevelInfo:
46       name = @"INFO";
47       break;
48     case NGLogLevelWarn:
49       name = @"WARN";
50       break;
51     case NGLogLevelError:
52       name = @"ERROR";
53       break;
54     case NGLogLevelFatal:
55       name = @"FATAL";
56       break;
57     default:
58       name = @"";
59       break;
60   }
61   return name;
62 }
63
64 @end