jens@0: // jens@0: // Logging.h jens@0: // MYUtilities jens@0: // jens@0: // Created by Jens Alfke on 1/5/08. jens@0: // Copyright 2008 Jens Alfke. All rights reserved. jens@0: // jens@0: jens@0: #import jens@0: jens@0: jens@0: NSString* LOC( NSString *key ); // Localized string lookup jens@0: jens@0: jens@1: #define Log(FMT,ARGS...) do{if(__builtin_expect(_gShouldLog,0)) _Log(FMT,##ARGS);}while(0) jens@0: #define Warn Warn jens@0: jens@0: void AlwaysLog( NSString *msg, ... ) __attribute__((format(__NSString__, 1, 2))); jens@0: jens@1: #define LogTo(DOMAIN,FMT,ARGS...) do{if(__builtin_expect(_gShouldLog,0)) _LogTo(@""#DOMAIN,FMT,##ARGS);}while(0) jens@0: jens@1: BOOL _WillLogTo( NSString *domain ); jens@1: BOOL EnableLog( BOOL enable ); jens@1: #define EnableLogTo( DOMAIN, VALUE ) _EnableLogTo(@""#DOMAIN, VALUE) jens@1: #define WillLogTo( DOMAIN ) _WillLogTo(@""#DOMAIN) jens@1: jens@1: jens@1: // internals; don't use directly jens@1: extern int _gShouldLog; jens@0: void _Log( NSString *msg, ... ) __attribute__((format(__NSString__, 1, 2))); jens@0: void Warn( NSString *msg, ... ) __attribute__((format(__NSString__, 1, 2))); jens@1: void _LogTo( NSString *domain, NSString *msg, ... ) __attribute__((format(__NSString__, 2, 3))); jens@1: BOOL _WillLogTo( NSString *domain ); jens@1: BOOL _EnableLogTo( NSString *domain, BOOL enable );