X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=sope-core%2FNGExtensions%2FNGExtensions%2FNGLogger.h;h=a25af2191842a0ea9a9c480d8bcf545dd8d00c44;hb=d11a3fe694759d997124a08e12aa7508d94df949;hp=da894ebb3c6295fc921c27af57d1ea2ec142441f;hpb=1cfb660b54e7c7061fe31a17f5b5e35b9ec7288d;p=sope diff --git a/sope-core/NGExtensions/NGExtensions/NGLogger.h b/sope-core/NGExtensions/NGExtensions/NGLogger.h index da894ebb..a25af219 100644 --- a/sope-core/NGExtensions/NGExtensions/NGLogger.h +++ b/sope-core/NGExtensions/NGExtensions/NGLogger.h @@ -1,20 +1,20 @@ /* - Copyright (C) 2004 SKYRIX Software AG + Copyright (C) 2004-2005 SKYRIX Software AG - This file is part of OpenGroupware.org. + This file is part of SOPE. - OGo is free software; you can redistribute it and/or modify it under + SOPE 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 + SOPE 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 + License along with SOPE; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ @@ -29,25 +29,66 @@ only if this minimum log level is satisfied - otherwise it silently drops these messages. - Note: Except in rare circumstances, do not allocate loggers yourself. Always - try to use the appropriate API of NGLoggerManager if possible. + NGLogger also offers a factory to instantiate loggers from configs stored + in NSUserDefaults. + + NOTE: Except in rare circumstances, do not allocate loggers yourself! + Always try to use the appropriate API of NGLoggerManager if possible. + + + NGLogger honours the following user default keys: + + User Default key Function + ---------------------------------------------------------------------------- + NGLogDefaultLogLevel The log level to use as a fallback, if no + log level is provided during initialization. + The default is "INFO". + + + The following keys in the configuration dictionary will be recognized: + + Key Function + ---------------------------------------------------------------------------- + "LogLevel" The log level to use for this logger. If no + log level is provided, sets log level according + to fallback described above. + + "Appenders" Array of dictionaries suitable as configuration + provided to NGLogAppender's factory method. + Please see NGLogAppender.h for further + explanation. + + LoggerConfig example: + + WOHttpTransactionLoggerConfig = { + "LogLevel" = "INFO"; + "Appenders" = ( + { + "Class" = "NGLogStdoutAppender"; + "Formatter" = { + "Class" = "NGLogEventFormatter"; + }; + }, + ); + }; - Note: Currently the NGLogger implementation lacks an API for configuring - appenders. Until this has been done appropriately, use the - "NGLogDefaultAppenderClass" user default to select an appropriate - default appender. If this default isn't set, "NGLogConsoleAppender" - is used. */ #import #include +@class NSMutableArray, NSString, NSDictionary, NGLogAppender; + @interface NGLogger : NSObject { - NGLogLevel logLevel; - id _appender; // going away as soon as we have a config + NSMutableArray *appenders; + @public + NGLogLevel logLevel; } ++ (id)loggerWithConfigFromUserDefaults:(NSString *)_defaultName; + +- (id)initWithConfig:(NSDictionary *)_config; - (id)initWithLogLevel:(NGLogLevel)_level; /* accessors */ @@ -55,10 +96,12 @@ - (void)setLogLevel:(NGLogLevel)_level; - (NGLogLevel)logLevel; +- (void)addAppender:(NGLogAppender *)_appender; +- (void)removeAppender:(NGLogAppender *)_appender; - /* logging */ +- (void)logLevel:(NGLogLevel)_level message:(NSString *)_msg; /* conditions */