2004-11-17 Marcus Mueller <znek@mulle-kybernetik.com>
+ * NGLogging: updated (v4.5.132)
+
* NGLogging: updated (v4.5.131)
2004-11-17 Matthew Joyce <mjoyce@aboveit.nl>
#define __NGExtensions_NGLogAppender_H_
/*
+ NGLogAppender
+
Abstract superclass for all log appenders.
*/
#ifndef __NGExtensions_NGLogConsoleAppender_H_
#define __NGExtensions_NGLogConsoleAppender_H_
+/*
+ NGLogConsoleAppender
+
+ A very simple console appender. The current implementation logs the
+ formatted event via NSLog(). Please note that doing so discards the timestamp
+ saved in the event, so the logged time isn't really exact, but will probably
+ only differ marginally.
+*/
+
#include <NGExtensions/NGLogAppender.h>
@interface NGLogConsoleAppender : NGLogAppender
#ifndef __NGExtensions_NGLogEvent_H_
#define __NGExtensions_NGLogEvent_H_
+/*
+ NGLogEvent
+
+ Instances of this class encapsulate log events, retaining all vital
+ information associated with it. Log events are generally passed on to
+ log appenders for further treatment.
+*/
+
#import <Foundation/NSObject.h>
#import <Foundation/NSDate.h>
#ifndef __NGExtensions_NGLogSyslogAppender_H_
#define __NGExtensions_NGLogSyslogAppender_H_
-#include <NGExtensions/NGLogAppender.h>
-
/*
NGLogSyslogAppender
- An appender which writes to the systems syslog facility.
+ An appender which writes to the system's syslog facility.
+
+ Use the user default key "NGLogSyslogIdentifier" to set the syslog
+ identifier. The syslog identifier is a string that will be prepended to every
+ message. See your operating system's manpage on syslog for details.
+
+ Note: syslog doesn't support user provided timestamps, thus this information
+ provided by NGLogEvent is silently discarded.
+
+ The following scheme is used to map NGLogLevels to syslog's levels:
+
+ NGLogLevel syslog
+ --------------------------
+ NGLogLevelDebug LOG_DEBUG
+ NGLogLevelInfo LOG_INFO
+ NGLogLevelWarn LOG_WARNING
+ NGLogLevelError LOG_ERR
+ NGLogLevelFatal LOG_ALERT
*/
+#include <NGExtensions/NGLogAppender.h>
+
@class NSString;
@interface NGLogSyslogAppender : NGLogAppender
/*
NGLogger
- A logger class, modeled closely after Log4J.
-
- TODO: explain more.
+ NGLogger has a minimum log level and passes messages to its appenders
+ 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.
+
+ 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 <Foundation/NSObject.h>
#ifndef __NGExtensions_NGLoggerManager_H_
#define __NGExtensions_NGLoggerManager_H_
+/*
+ NGLoggerManager
+
+ Manages a set of loggers by associating logger instances with names. Thus
+ clients will be given the same instances if accessing the manager with the
+ same name/key. Also, NGLoggerManager offers conditional creation of loggers
+ based on user default keys (and special values associated with these keys).
+
+ It's planned that NGLoggerManager will be provided with a configuration of
+ some sort at a later stage, so configuration of log levels and appenders for
+ loggers can reach a similar dynamism as is currently achieved in Log4J.
+*/
+
#import <Foundation/NSObject.h>
@class NSString, NSMutableDictionary;
+ (id)defaultLoggerManager;
-/* operations */
-
+/* Retrieves a logger conditional to the existence of the given default key.
+ In order to stay backwards compatible to existing applications, a boolean
+ value auf YES associated with this key sets the default log level of this
+ logger to NGLogLevelDebug. Other possible values for this key include
+ "DEBUG, "INFO", "WARN", "ERROR" and "FATAL". Everything else will be mapped
+ to NGLogLevelAll. If the requested default key is not set, *nil* is
+ returned.
+*/
- (NGLogger *)loggerForDefaultKey:(NSString *)_defaultKey;
+/* Retrieves a "named" logger with NGLogLevelAll. */
+- (NGLogger *)loggerForFacilityNamed:(NSString *)_name;
+- (NGLogger *)loggerForClass:(Class)_clazz;
+
@end
#endif /* __NGExtensions_NGLoggerManager_H_ */
#define __NGExtensions_NGLogging_H_
/*
- NGLogging is a somewhat more sophisticated logging framework, modeled
- apparently similar to log4j - without some of its bloat.
+ NGLogging is a new logging framework, modeled in a similar fashion as Log4J
+ - without some of its bloat.
+
+ Documentation is currently provided in the headers only.
*/
#include <NGExtensions/NSObject+ExtendedLogging.h>
#ifndef __NSObject_ExtendedLogging_H_
#define __NSObject_ExtendedLogging_H_
+/*
+ Logging convenience for the new NGLogger based API.
+
+ The default implementation uses the "NGDefaultLogLevel" user default key to
+ retrieve a logger from the NGLoggerManager. If this default isn't set,
+ a default logger with log level NGLogLevelInfo will be instantiated.
+
+ Consult the header of NGLoggerManager for further details on setting the
+ "NGDefaultLogLevel" user default.
+*/
+
#import <Foundation/NSObject.h>
typedef enum {
@interface NSObject(NGExtendedLogging)
++ (id)logger;
- (id)logger;
/* convenience methods */
2004-11-17 Marcus Mueller <znek@mulle-kybernetik.com>
+ * *.h: provided some documentation
+
+ * NGLoggerManager.[hm]: new method -loggerForFacilityNamed: for
+ sharing/referencing instances based on names.
+
* NSObject+NGExtendedLogging.h: fixed some serious misordering in
log levels (thanks to Helge Hess for reporting this! ;-)
return (logger != sharedNull) ? logger : nil;
}
+- (NGLogger *)loggerForFacilityNamed:(NSString *)_name {
+ id logger;
+
+ logger = [self->loggerMap objectForKey:_name];
+ if (!logger) {
+ logger = [[NGLogger alloc] init];
+ [self->loggerMap setObject:logger forKey:_name];
+ [logger release];
+ }
+ return logger;
+}
+
+- (NGLogger *)loggerForClass:(Class)_clazz {
+ NSString *name;
+
+ name = NSStringFromClass(_clazz);
+ return [self loggerForFacilityNamed:name];
+}
+
+
/* Private */
- (NGLogLevel)_logLevelForString:(NSString *)_defaultValue {
@implementation NSObject(NGExtendedLogging)
-- (id)logger {
- static id sharedLogger = nil;
- static BOOL shouldLog = YES;
++ (id)logger {
+ static id sharedLogger = nil;
- if (sharedLogger == nil && shouldLog) {
+ if (sharedLogger == nil) {
NGLoggerManager *lm;
-
+
lm = [NGLoggerManager defaultLoggerManager];
sharedLogger = [lm loggerForDefaultKey:@"NGDefaultLogLevel"];
- if (!sharedLogger)
- shouldLog = NO;
+ if (!sharedLogger) {
+ sharedLogger = [lm loggerForFacilityNamed:@"root"];
+ [sharedLogger setLogLevel:NGLogLevelInfo];
+ }
}
return sharedLogger;
}
+- (id)logger {
+ return [[self class] logger];
+}
+
/* log methods */
- (void)logDebugWithFormat:(NSString *)_fmt, ... {
va_list va;
logger = [self logger];
- if(![logger isLogDebugEnabled])
+ if (![logger isLogDebugEnabled])
return;
va_start(va, _fmt);
va_list va;
logger = [self logger];
- if(![logger isLogInfoEnabled])
+ if (![logger isLogInfoEnabled])
return;
va_start(va, _fmt);
va_list va;
logger = [self logger];
- if(![logger isLogWarnEnabled])
+ if (![logger isLogWarnEnabled])
return;
va_start(va, _fmt);
va_list va;
logger = [self logger];
- if(![logger isLogErrorEnabled])
+ if (![logger isLogErrorEnabled])
return;
va_start(va, _fmt);
va_list va;
logger = [self logger];
- if(![logger isLogFatalEnabled])
+ if (![logger isLogFatalEnabled])
return;
va_start(va, _fmt);
# version
-SUBMINOR_VERSION:=131
+SUBMINOR_VERSION:=132
# v4.3.115 requires libFoundation v1.0.59
# v4.2.72 requires libEOControl v4.2.39