linux c++调试日志函数

#ifndef MYLOG_H
#define MYLOG_H

#include <stdio.h>

#define __DEBUG__
#ifdef __DEBUG__  
#define DEBUG(format,...) printf("File: "__FILE__", Line: %d: "format"\n", __LINE__, ##__VA_ARGS__)  
#define detail(format, args...) printf("debug[%s|%s|%d]/t"format"\n",__FILE__,__func__,__LINE__,##args)
#define info(format, args...)   printf("info[%s|%s|%d]/t"format"\n",__FILE__,__func__,__LINE__,##args)
#define warn(format, args...)   printf("warn[%s|%s|%d]/t"format"\n",__FILE__,__func__,__LINE__,##args)
#define error(format, args...)  printf("error[%s|%s|%d]/t"format"\n",__FILE__,__func__,__LINE__,##args)
#else  
#define DEBUG(format,...)  
#define detail(format, args...)
#define info(format, args...) 
#define warn(format, args...) 
#define error(format, args...) 
#endif 

#endif

#include <iostream>
using namespace std;

int main() {  
  
    string straab = "asdf";
    DEBUG("aaa-%s",straab.c_str());

    return 0; 
}  

  

猜你喜欢

转载自www.cnblogs.com/mingyue605/p/10982259.html
今日推荐