]> err.no Git - sope/blob - sope-core/NGExtensions/NGExtensions/NGLogger.h
fixed copyrights for 2005
[sope] / sope-core / NGExtensions / NGExtensions / NGLogger.h
1 /*
2   Copyright (C) 2004-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21
22 #ifndef __NGExtensions_NGLogger_H_
23 #define __NGExtensions_NGLogger_H_
24
25 /*
26   NGLogger
27   
28   NGLogger has a minimum log level and passes messages to its appenders
29   only if this minimum log level is satisfied - otherwise it silently drops
30   these messages.
31
32   NGLogger also offers a factory to instantiate loggers from configs stored
33   in NSUserDefaults.
34
35   NOTE: Except in rare circumstances, do not allocate loggers yourself!
36         Always try to use the appropriate API of NGLoggerManager if possible.
37
38
39   NGLogger honours the following user default keys:
40
41   User Default key              Function
42   ----------------------------------------------------------------------------
43   NGLogDefaultLogLevel          The log level to use as a fallback, if no
44                                 log level is provided during initialization.
45                                 The default is "INFO".
46
47  
48   The following keys in the configuration dictionary will be recognized:
49  
50   Key                           Function
51   ----------------------------------------------------------------------------
52   "LogLevel"                    The log level to use for this logger. If no
53                                 log level is provided, sets log level according
54                                 to fallback described above.
55
56   "Appenders"                   Array of dictionaries suitable as configuration
57                                 provided to NGLogAppender's factory method.
58                                 Please see NGLogAppender.h for further
59                                 explanation.
60
61   LoggerConfig example:
62  
63   WOHttpTransactionLoggerConfig = {
64     "LogLevel"  = "INFO";
65     "Appenders" = (
66       {
67         "Class"     = "NGLogStdoutAppender";
68         "Formatter" = {
69           "Class" = "NGLogEventFormatter";
70         };
71       },
72     );
73   };
74  
75 */
76
77 #import <Foundation/NSObject.h>
78 #include <NGExtensions/NGLogLevel.h>
79
80 @class NSMutableArray, NSString, NSDictionary, NGLogAppender;
81
82 @interface NGLogger : NSObject
83 {
84   NSMutableArray *appenders;
85   @public
86   NGLogLevel     logLevel;
87 }
88
89 + (id)loggerWithConfigFromUserDefaults:(NSString *)_defaultName;
90
91 - (id)initWithConfig:(NSDictionary *)_config;
92 - (id)initWithLogLevel:(NGLogLevel)_level;
93
94 /* accessors */
95
96 - (void)setLogLevel:(NGLogLevel)_level;
97 - (NGLogLevel)logLevel;
98
99 - (void)addAppender:(NGLogAppender *)_appender;
100 - (void)removeAppender:(NGLogAppender *)_appender;
101
102 /* logging */
103
104 - (void)logLevel:(NGLogLevel)_level message:(NSString *)_msg;
105
106 /* conditions */
107
108 - (BOOL)isDebuggingEnabled;
109 - (BOOL)isLogInfoEnabled;
110 - (BOOL)isLogWarnEnabled;
111 - (BOOL)isLogErrorEnabled;
112 - (BOOL)isLogFatalEnabled;
113   
114 @end
115
116 #endif  /* __NGExtensions_NGLogger_H_ */