2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OGo
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
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.
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
25 #include <NGExtensions/NGExtensions.h>
27 #include "NGLogEvent.h"
28 #include "NGLogAppender.h"
29 #include "NGLogConsoleAppender.h"
32 @implementation NGLogger
35 self = [self initWithLogLevel:NGLogLevelAll];
39 - (id)initWithLogLevel:(NGLogLevel)_level {
40 if((self = [super init])) {
41 [self setLogLevel:_level];
42 #warning ** remove this as soon as we have a config
43 self->_appender = [[NGLogConsoleAppender alloc] init];
49 [self->_appender release];
54 - (void)setLogLevel:(NGLogLevel)_level {
55 self->minLogLevel = _level;
58 - (NGLogLevel)logLevel {
59 return self->minLogLevel;
62 - (void)logLevel:(NGLogLevel)_level withFormat:(NSString *)_fmt, ... {
67 if(self->minLogLevel > _level)
71 msg = [[NSString alloc] initWithFormat:_fmt arguments:va];
74 event = [[NGLogEvent alloc] initWithLevel:_level message:msg];
77 // TODO: as soon as we have more appenders, we need to iterate on them
78 [self->_appender appendLogEvent:event];
84 - (BOOL)isLogDebugEnabled {
85 return self->minLogLevel >= NGLogLevelDebug;
88 - (BOOL)isLogInfoEnabled {
89 return self->minLogLevel >= NGLogLevelInfo;
92 - (BOOL)isLogWarnEnabled {
93 return self->minLogLevel >= NGLogLevelWarn;
96 - (BOOL)isLogErrorEnabled {
97 return self->minLogLevel >= NGLogLevelError;
100 - (BOOL)isLogFatalEnabled {
101 return self->minLogLevel >= NGLogLevelFatal;