Last active
December 19, 2015 12:19
-
-
Save uzysjung/5953947 to your computer and use it in GitHub Desktop.
Enable NSLog in Debug mode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// DebugLog.h | |
// Uzys DebugLog | |
// | |
// Created by UzysJung on 13. 2. 25.. | |
// Copyright (c) 2013년 Uzys. All rights reserved. | |
// | |
/* | |
How to use | |
Project -> Build Settings -> Apple LLVM Compiler Preprocessing -> Preprocessor Macro - > debug -> 'DEBUG = 1' | |
*/ | |
#ifdef DEBUG | |
#include <libgen.h> | |
#define DLogm() NSLog(@"[%s:%d %@]",basename(__FILE__),__LINE__,NSStringFromSelector(_cmd)) | |
#define DLog(format, ...) NSLog(@"[%s:%d %@] %@",basename(__FILE__),__LINE__,NSStringFromSelector(_cmd),[NSString stringWithFormat:format, ## __VA_ARGS__]) | |
#define DLogv(var) NSLog(@"[%s:%d %@] "# var "=%@",basename(__FILE__),__LINE__,NSStringFromSelector(_cmd), var) | |
#define DLOG_EXPR(_X_) do{\ | |
__typeof__(_X_) _Y_ = (_X_);\ | |
const char * _TYPE_CODE_ = @encode(__typeof__(_X_));\ | |
NSString *_STR_ = VTPG_DDToStringFromTypeAndValue(_TYPE_CODE_, &_Y_);\ | |
if(_STR_)\ | |
NSLog(@"%s = %@", #_X_, _STR_);\ | |
else\ | |
NSLog(@"Unknown _TYPE_CODE_: %s for expression %s in function %s, file %s, line %d", _TYPE_CODE_, #_X_, __func__, __FILE__, __LINE__);\ | |
}while(0) | |
#else | |
#define DLogm() | |
#define DLog(format, ...) | |
#define DLogv(var) | |
#define DLOG_EXPR(_X_) | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment