see ChangeLog

Monotone-Revision: 9054022ef1ca8aeba6e34842d27d9b94ce002b89

Monotone-Author: dev-unix.inverse.qc.ca
Monotone-Date: 2006-06-15T19:34:10
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
dev-unix.inverse.qc.ca
2006-06-15 19:34:10 +00:00
commit f18c764ffa
965 changed files with 99196 additions and 0 deletions
@@ -0,0 +1,17 @@
2004-05-27 Marcus Mueller <mm@skyrix.com>
* NGLogAppender.[hm]: introduced -formattedEvent:, currently not
configurable.
* NGLogSyslogAppender.m: works as expected now.
* NGLogger.m: uses new default (see README) to select the default
appender. Not optimal, but sufficient.
* NGLogConsoleAppender.m: changed to use -formattedEvent: now.
2004-05-27 Marcus Mueller <mm@skyrix.com>
* NGLogSyslogAppender.[hm]: syslog appender, untested.
* ChangeLog: created
@@ -0,0 +1,30 @@
# $Id$
include $(GNUSTEP_MAKEFILES)/common.make
SUBPROJECT_NAME = NGLogging
ADDITIONAL_INCLUDE_DIRS += -I.. -I../..
NGLogging_OBJC_FILES = \
NSObject+ExtendedLogging.m \
NGLogger.m \
NGLogEvent.m \
NGLogAppender.m \
NGLogConsoleAppender.m \
NGLogging_HEADER_FILES = \
NGLogging.h \
NSObject+ExtendedLogging.h \
NGLogger.h \
NGLogEvent.h \
NGLogAppender.h \
NGLogConsoleAppender.h \
-include GNUmakefile.preamble
include $(GNUSTEP_MAKEFILES)/subproject.make
-include GNUmakefile.postamble
@@ -0,0 +1,51 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#ifndef __NGLogAppender_H_
#define __NGLogAppender_H_
/*
Abstract superclass for all appenders.
*/
#import <Foundation/Foundation.h>
#import "NSObject+ExtendedLogging.h"
@class NGLogEvent;
@interface NGLogAppender : NSObject
{
}
/* subclass responsibility */
- (void)appendLogEvent:(NGLogEvent *)_event;
- (NSString *)formattedEvent:(NGLogEvent *)_event;
- (NSString *)localizedNameOfLogLevel:(NGLogLevel)_level;
@end
#endif /* __NGLogAppender_H_ */
@@ -0,0 +1,66 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#import "NGLogAppender.h"
#import "NGLogEvent.h"
@implementation NGLogAppender
- (void)appendLogEvent:(NGLogEvent *)_event {
[self subclassResponsibility:_cmd];
}
- (NSString *)formattedEvent:(NGLogEvent *)_event {
return [NSString stringWithFormat:@"[%@] %@",
[self localizedNameOfLogLevel:[_event level]],
[_event message]];
}
- (NSString *)localizedNameOfLogLevel:(NGLogLevel)_level {
NSString *name;
switch (_level) {
case NGLogLevelDebug:
name = @"DEBUG";
break;
case NGLogLevelInfo:
name = @"INFO";
break;
case NGLogLevelWarn:
name = @"WARN";
break;
case NGLogLevelError:
name = @"ERROR";
break;
case NGLogLevelFatal:
name = @"FATAL";
break;
default:
name = @"";
break;
}
return name;
}
@end
@@ -0,0 +1,38 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#ifndef __NGLogConsoleAppender_H_
#define __NGLogConsoleAppender_H_
#import "NGLogAppender.h"
@interface NGLogConsoleAppender : NGLogAppender
{
}
@end
#endif /* __NGLogConsoleAppender_H_ */
@@ -0,0 +1,34 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#import "NGLogConsoleAppender.h"
#import "NGLogEvent.h"
@implementation NGLogConsoleAppender
- (void)appendLogEvent:(NGLogEvent *)_event {
NSLog([self formattedEvent:_event]);
}
@end
@@ -0,0 +1,47 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#ifndef __NGLogEvent_H_
#define __NGLogEvent_H_
#import <Foundation/Foundation.h>
#import "NSObject+ExtendedLogging.h"
@interface NGLogEvent : NSObject
{
NSString *msg;
NGLogLevel level;
NSTimeInterval date;
}
- (id)initWithLevel:(NGLogLevel)_level message:(NSString *)_msg;
- (NGLogLevel)level;
- (NSString *)message;
- (NSDate *)date;
@end
#endif /* __NGLogEvent_H_ */
@@ -0,0 +1,56 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#import "NGLogEvent.h"
#import <NGExtensions/NGExtensions.h>
@implementation NGLogEvent
- (id)initWithLevel:(NGLogLevel)_level message:(NSString *)_msg {
if((self = [super init])) {
self->date = [NSDate timeIntervalSinceReferenceDate];
self->level = _level;
ASSIGN(self->msg, _msg);
}
return self;
}
- (void)dealloc {
[self->msg release];
[super dealloc];
}
- (NGLogLevel)level {
return self->level;
}
- (NSString *)message {
return self->msg;
}
- (NSDate *)date {
return [NSDate dateWithTimeIntervalSinceReferenceDate:self->date];
}
@end
@@ -0,0 +1,43 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#ifndef __NGLogSyslogAppender_H_
#define __NGLogSyslogAppender_H_
#import "NGLogAppender.h"
@interface NGLogSyslogAppender : NGLogAppender
{
}
+ (id)sharedAppender;
/* provide syslog identifier */
- (id)initWithIdentifier:(NSString *)_ident;
@end
#endif /* __NGLogSyslogAppender_H_ */
@@ -0,0 +1,114 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#import "NGLogSyslogAppender.h"
#import "NGLogEvent.h"
#include <syslog.h>
#include <stdarg.h>
@interface NGLogSyslogAppender (PrivateAPI)
- (int)syslogLevelForLogLevel:(NGLogLevel)_level;
@end
@implementation NGLogSyslogAppender
static NSString *defaultSyslogIdentifier = nil;
+ (void)initialize {
NSUserDefaults *ud;
static BOOL isInitialized = NO;
if(isInitialized)
return;
ud = [NSUserDefaults standardUserDefaults];
defaultSyslogIdentifier =
[[ud stringForKey:@"NGLogSyslogIdentifier"] retain];
isInitialized = YES;
}
+ (id)sharedAppender {
static id sharedAppender = nil;
if(sharedAppender == nil) {
sharedAppender = [[self alloc] init];
}
return sharedAppender;
}
- (id)init {
return [self initWithIdentifier:defaultSyslogIdentifier];
}
- (id)initWithIdentifier:(NSString *)_ident {
if((self = [super init])) {
#warning ** default flags?
openlog([_ident cString], LOG_PID | LOG_NDELAY, LOG_USER);
}
return self;
}
- (void)dealloc {
closelog();
[super dealloc];
}
- (void)appendLogEvent:(NGLogEvent *)_event {
NSString *formattedMsg;
int level;
formattedMsg = [self formattedEvent:_event];
level = [self syslogLevelForLogLevel:[_event level]];
syslog(level, [formattedMsg cString]);
}
- (int)syslogLevelForLogLevel:(NGLogLevel)_level {
int level;
switch (_level) {
case NGLogLevelDebug:
level = LOG_DEBUG;
break;
case NGLogLevelInfo:
level = LOG_INFO;
break;
case NGLogLevelWarn:
level = LOG_WARNING;
break;
case NGLogLevelError:
level = LOG_ERR;
break;
case NGLogLevelFatal:
level = LOG_ALERT; // LOG_EMERG is broadcast to all users...
break;
default:
level = LOG_NOTICE;
break;
}
return level;
}
@end
@@ -0,0 +1,49 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#ifndef __NGLogger_H_
#define __NGLogger_H_
/*
The logger, modeled closely after log4j.
*/
#import <Foundation/Foundation.h>
#include "NSObject+ExtendedLogging.h"
@interface NGLogger : NSObject
{
NGLogLevel minLogLevel;
id _appender; // going away as soon as we have a config
}
- (id)initWithLogLevel:(NGLogLevel)_level;
- (void)setLogLevel:(NGLogLevel)_level;
- (NGLogLevel)logLevel;
@end
#endif /* __NGLogger_H_ */
@@ -0,0 +1,111 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#include "NGLogger.h"
#include <NGExtensions/NGExtensions.h>
#include "common.h"
#include "NGLogEvent.h"
#include "NGLogAppender.h"
@implementation NGLogger
- (id)init {
self = [self initWithLogLevel:NGLogLevelAll];
return self;
}
- (id)initWithLogLevel:(NGLogLevel)_level {
if((self = [super init])) {
NSUserDefaults *ud;
NSString *appenderClassName;
[self setLogLevel:_level];
#warning ** remove this as soon as we have a config
ud = [NSUserDefaults standardUserDefaults];
appenderClassName = [ud stringForKey:@"NGLogDefaultAppenderClass"];
if(appenderClassName == nil)
appenderClassName = @"NGLogConsoleAppender";
self->_appender = [[NSClassFromString(appenderClassName) alloc] init];
}
return self;
}
- (void)dealloc {
[self->_appender release];
[super dealloc];
}
- (void)setLogLevel:(NGLogLevel)_level {
self->minLogLevel = _level;
}
- (NGLogLevel)logLevel {
return self->minLogLevel;
}
- (void)logLevel:(NGLogLevel)_level withFormat:(NSString *)_fmt, ... {
NSString *msg;
NGLogEvent *event;
va_list va;
if(self->minLogLevel > _level)
return;
va_start(va, _fmt);
msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
va_end(va);
event = [[NGLogEvent alloc] initWithLevel:_level message:msg];
// iterate appenders
// TODO: as soon as we have more appenders, we need to iterate on them
[self->_appender appendLogEvent:event];
[event release];
[msg release];
}
- (BOOL)isLogDebugEnabled {
return self->minLogLevel >= NGLogLevelDebug;
}
- (BOOL)isLogInfoEnabled {
return self->minLogLevel >= NGLogLevelInfo;
}
- (BOOL)isLogWarnEnabled {
return self->minLogLevel >= NGLogLevelWarn;
}
- (BOOL)isLogErrorEnabled {
return self->minLogLevel >= NGLogLevelError;
}
- (BOOL)isLogFatalEnabled {
return self->minLogLevel >= NGLogLevelFatal;
}
@end
@@ -0,0 +1,42 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#ifndef __NGLogging_H_
#define __NGLogging_H_
/*
NGLogging is a somewhat more sophisticated logging framework, modeled
apparently similar to log4j - without some of its bloat. The current
idea is to replace the default logging used throughout OGo (-logWithFormat:,
-debugWithFormat:, NSLog()) with the new logging framework to get rid of
stdout only logging.
*/
#import <Foundation/Foundation.h>
#include "NSObject+ExtendedLogging.h"
#include "NGLogger.h"
#endif /* __NGLogging_H_ */
@@ -0,0 +1,63 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#ifndef __NSObject_ExtendedLogging_H_
#define __NSObject_ExtendedLogging_H_
#import <Foundation/Foundation.h>
typedef enum {
NGLogLevelAll = 0,
NGLogLevelDebug = 1,
NGLogLevelInfo = 2,
NGLogLevelWarn = 3,
NGLogLevelError = 4,
NGLogLevelFatal = 5,
NGLogLevelOff = 6
} NGLogLevel;
@interface NSObject (NGExtendedLogging)
- (id)sharedLogger;
- (id)logger;
- (void)logDebugWithFormat:(NSString *)_fmt, ...;
- (void)logInfoWithFormat:(NSString *)_fmt, ...;
- (void)logWarnWithFormat:(NSString *)_fmt, ...;
- (void)logErrorWithFormat:(NSString *)_fmt, ...;
- (void)logFatalWithFormat:(NSString *)_fmt, ...;
- (BOOL)isLogDebugEnabled;
- (BOOL)isLogInfoEnabled;
- (BOOL)isLogWarnEnabled;
- (BOOL)isLogErrorEnabled;
- (BOOL)isLogFatalEnabled;
- (void)logLevel:(NGLogLevel)_level withFormat:(NSString *)_fmt, ...;
@end
#endif /* __NSObject_ExtendedLogging_H_ */
@@ -0,0 +1,128 @@
/*
Copyright (C) 2000-2004 SKYRIX Software AG
This file is part of OGo
OGo 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
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
Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
// $Id$
#import "NSObject+ExtendedLogging.h"
#import "NGLogger.h"
@implementation NSObject (NGExtendedLogging)
- (id)sharedLogger {
static id sharedLogger = nil;
if(sharedLogger == nil) {
sharedLogger = [[NGLogger alloc] init];
}
return sharedLogger;
}
- (id)logger {
return [self sharedLogger];
}
- (void)logDebugWithFormat:(NSString *)_fmt, ... {
NSString *msg;
va_list va;
va_start(va, _fmt);
msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
va_end(va);
[self logLevel:NGLogLevelDebug withFormat:msg];
[msg release];
}
- (void)logInfoWithFormat:(NSString *)_fmt, ... {
NSString *msg;
va_list va;
va_start(va, _fmt);
msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
va_end(va);
[self logLevel:NGLogLevelInfo withFormat:msg];
[msg release];
}
- (void)logWarnWithFormat:(NSString *)_fmt, ... {
NSString *msg;
va_list va;
va_start(va, _fmt);
msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
va_end(va);
[self logLevel:NGLogLevelWarn withFormat:msg];
[msg release];
}
- (void)logErrorWithFormat:(NSString *)_fmt, ... {
NSString *msg;
va_list va;
va_start(va, _fmt);
msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
va_end(va);
[self logLevel:NGLogLevelError withFormat:msg];
[msg release];
}
- (void)logFatalWithFormat:(NSString *)_fmt, ... {
NSString *msg;
va_list va;
va_start(va, _fmt);
msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
va_end(va);
[self logLevel:NGLogLevelFatal withFormat:msg];
[msg release];
}
- (void)logLevel:(NGLogLevel)_level withFormat:(NSString *)_fmt, ... {
NSString *msg;
va_list va;
va_start(va, _fmt);
msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
va_end(va);
[[self logger] logLevel:_level withFormat:msg];
[msg release];
}
- (BOOL)isLogDebugEnabled {
return [[self logger] isLogDebugEnabled];
}
- (BOOL)isLogInfoEnabled {
return [[self logger] isLogInfoEnabled];
}
- (BOOL)isLogWarnEnabled {
return [[self logger] isLogWarnEnabled];
}
- (BOOL)isLogErrorEnabled {
return [[self logger] isLogErrorEnabled];
}
- (BOOL)isLogFatalEnabled {
return [[self logger] isLogFatalEnabled];
}
@end