2 Copyright (C) 2000-2004 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
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
22 #include "NSObject+Logs.h"
25 @implementation NSObject(NGLogs)
27 static Class StringClass = Nil;
29 static inline Class NSStringClass(void) {
30 if (StringClass == Nil) StringClass = [NSString class];
34 - (BOOL)isDebuggingEnabled {
41 - (NSString *)loggingPrefix {
42 /* improve perf ... */
43 return [NSStringClass() stringWithFormat:@"<0x%08X[%@]>",
44 self, NSStringFromClass([self class])];
47 - (void)logWithFormat:(NSString *)_format arguments:(va_list)ap {
48 NSString *value = nil;
50 value = [[NSStringClass() alloc] initWithFormat:_format arguments:ap];
51 NSLog(@"%@ %@", [self loggingPrefix], value);
55 - (void)debugWithFormat:(NSString *)_format arguments:(va_list)ap {
57 NSString *value = nil;
59 if (![self isDebuggingEnabled]) return;
61 value = [[NSStringClass() alloc] initWithFormat:_format arguments:ap];
62 NSLog(@"<%@>D %@", [self loggingPrefix], value);
65 # warning debug is disabled, debugWithFormat wont print anything ..
69 - (void)logWithFormat:(NSString *)_format, ... {
72 va_start(ap, _format);
73 [self logWithFormat:_format arguments:ap];
76 - (void)debugWithFormat:(NSString *)_format, ... {
79 va_start(ap, _format);
80 [self debugWithFormat:_format arguments:ap];
84 @end /* NSObject(NGLogs) */