jens@0
|
1 |
//
|
jens@0
|
2 |
// Logging.h
|
jens@0
|
3 |
// MYUtilities
|
jens@0
|
4 |
//
|
jens@0
|
5 |
// Created by Jens Alfke on 1/5/08.
|
jens@0
|
6 |
// Copyright 2008 Jens Alfke. All rights reserved.
|
jens@0
|
7 |
//
|
jens@0
|
8 |
|
jens@0
|
9 |
#import <Cocoa/Cocoa.h>
|
jens@0
|
10 |
|
jens@0
|
11 |
|
jens@0
|
12 |
NSString* LOC( NSString *key ); // Localized string lookup
|
jens@0
|
13 |
|
jens@0
|
14 |
|
jens@1
|
15 |
#define Log(FMT,ARGS...) do{if(__builtin_expect(_gShouldLog,0)) _Log(FMT,##ARGS);}while(0)
|
jens@0
|
16 |
#define Warn Warn
|
jens@0
|
17 |
|
jens@0
|
18 |
void AlwaysLog( NSString *msg, ... ) __attribute__((format(__NSString__, 1, 2)));
|
jens@0
|
19 |
|
jens@1
|
20 |
#define LogTo(DOMAIN,FMT,ARGS...) do{if(__builtin_expect(_gShouldLog,0)) _LogTo(@""#DOMAIN,FMT,##ARGS);}while(0)
|
jens@0
|
21 |
|
jens@1
|
22 |
BOOL _WillLogTo( NSString *domain );
|
jens@1
|
23 |
BOOL EnableLog( BOOL enable );
|
jens@1
|
24 |
#define EnableLogTo( DOMAIN, VALUE ) _EnableLogTo(@""#DOMAIN, VALUE)
|
jens@1
|
25 |
#define WillLogTo( DOMAIN ) _WillLogTo(@""#DOMAIN)
|
jens@1
|
26 |
|
jens@1
|
27 |
|
jens@1
|
28 |
// internals; don't use directly
|
jens@1
|
29 |
extern int _gShouldLog;
|
jens@0
|
30 |
void _Log( NSString *msg, ... ) __attribute__((format(__NSString__, 1, 2)));
|
jens@0
|
31 |
void Warn( NSString *msg, ... ) __attribute__((format(__NSString__, 1, 2)));
|
jens@1
|
32 |
void _LogTo( NSString *domain, NSString *msg, ... ) __attribute__((format(__NSString__, 2, 3)));
|
jens@1
|
33 |
BOOL _WillLogTo( NSString *domain );
|
jens@1
|
34 |
BOOL _EnableLogTo( NSString *domain, BOOL enable );
|