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