Ignore:
Timestamp:
Mar 31, 2015, 5:56:39 PM (11 years ago)
Author:
rousseau
Message:

Made simple console logging a build option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/swt/include/dbglog.h

    r22041 r22092  
    1414#ifdef __cplusplus
    1515      extern "C" {
     16#endif
     17
     18// To enable global console logging, use 'kmk DBG_CON=' _or_ set 'DBG_CON='
     19// in LocalConfig.kmk _or_ set DBG_CON to some value in the environment.
     20// Per source console logging can be enabled by defining DBG_CON _before_
     21// the inclusion of the <misc.h> header.
     22#ifdef DBG_CON
     23#define PFXFMT  "**__con_debug(%d)** "
     24#define __con_debug(lvl, fmt, ...)\
     25switch (lvl) {\
     26  case 0:\
     27    break;\
     28  case 2:\
     29    printf(PFXFMT, lvl);\
     30    printf(fmt, __VA_ARGS__);\
     31    break;\
     32  case 3:\
     33    printf(PFXFMT"FUNCTION:%s ", lvl, __FUNCTION__);\
     34    printf(fmt, __VA_ARGS__);\
     35    break;\
     36  case 4:\
     37    printf(PFXFMT"FILE:%s FUNCTION:%s ", lvl, __FILE__, __FUNCTION__);\
     38    printf(fmt, __VA_ARGS__);\
     39    break;\
     40  case 5:\
     41    printf(PFXFMT, lvl);\
     42    printf(fmt, __VA_ARGS__);\
     43    break;\
     44  default:\
     45    printf(fmt, __VA_ARGS__);\
     46    break;\
     47}\
     48fflush(stdout)
     49#else
     50#define __con_debug(lvl, fmt, ...)
    1651#endif
    1752
Note: See TracChangeset for help on using the changeset viewer.