LoginSignup
11
11

More than 5 years have passed since last update.

# NSLog を Debug時のみ出力させる

Last updated at Posted at 2012-04-05

ALogDLogというマクロにして、使用したファイル名、関数(メソッド名)、行番号を NSLog で出力させる。

ALog は Release/Debug ビルド双方とも出るが、DLogは Debug ビルド時にしか出力しない。

TestFlight 対応

#ifdef DEBUG
#    ifndef DLog
#        define DLog(__FORMAT__,...) NSLog((@"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#    endif
#else
#    ifndef DLog
#        define DLog(...) /* */
#    endif
#endif /* if DEBUG */

#ifndef ALog
#  ifdef TFLog
#    define ALog(__FORMAT__, ...) TFLog((@"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#  else
#    define ALog(__FORMAT__,...) NSLog((@"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
#  endif /* ADHOC */
#endif
  • 2012/04/05 22:24 +0900: Typo fix
11
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
11