IM920地温観測システム CQ 2017ARMセミナー用サンプルプログラム

Dependencies:   C027_Support_ForIM920

Fork of C027_SupportTest by u-blox

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers DebugPrint.h Source File

DebugPrint.h

00001 #if !defined(__DEBUGPRINT_H__)
00002 #define __DEBUGPRINT_H__
00003 
00004 #define PDEBUG
00005 
00006 #ifdef PDEBUG
00007 // 0=ERROR 1=INFO 2=TRACE
00008 #define _debugLevel 2   // 出力レベル設定 0=NONE 1=ERROR 2=ERROR/INFO 3=ERROR/INFO/TRACE
00009  #if 1 // colored terminal output using ANSI escape sequences
00010   #define COL(c) "\033[" c
00011  #else
00012   #define COL(c) 
00013  #endif
00014  #define DEF COL("39m")
00015  #define BLA COL("30m")
00016  #define RED COL("31m")
00017  #define GRE COL("32m")
00018  #define YEL COL("33m")
00019  #define BLU COL("34m")
00020  #define MAG COL("35m")
00021  #define CYA COL("36m")
00022  #define WHY COL("37m")
00023  // ERROR()INFO()はログファイルにもOUT
00024  #define ERROR(...)     (_debugLevel < 0) ? : ::printf(RED), ::printf(__VA_ARGS__), ::printf(DEF)
00025  #define TEST(...)                            ::printf(CYA), ::printf(__VA_ARGS__), ::printf(DEF)  
00026  #define INFO(...)      (_debugLevel < 1) ? : ::printf(GRE), ::printf(__VA_ARGS__), ::printf(DEF)
00027  // Timestampなし
00028  #define INFO_NT(...)      (_debugLevel < 1) ? : ::printf(GRE), ::printf(__VA_ARGS__), ::printf(DEF)
00029 
00030  #define TRACE(...)     (_debugLevel < 2) ? : ::printf(__VA_ARGS__)
00031  #define TRACE_LN(...)     (_debugLevel < 2) ? : ::printf(__VA_ARGS__), ::printf("\r\n");
00032 
00033  #define TRACE_VARI(v)   TRACE("vari %s=%d\r\n", #v, v)
00034  #define TRACE_VARF(v)   TRACE("varf %s=%f\r\n", #v, v)
00035  #define TRACE_VARS(v)   TRACE("vars %s=%s\r\n", #v, v)
00036 #else
00037  
00038  #define ERROR(...) (void)0 // no tracing
00039  #define TEST(...)  (void)0 // no tracing
00040  #define INFO(...)  (void)0 // no tracing
00041  #define TRACE(...) (void)0 // no tracing
00042  #define TRACE_VARI(...) (void)0 // no tracing
00043  #define TRACE_VARS(...) (void)0 // no tracing
00044 
00045 #endif
00046 
00047 #endif