2017-07-24 21:18:58 +08:00
|
|
|
|
2017-09-01 17:40:55 -05:00
|
|
|
#ifndef UDP2RAW_LOG_MYLOG_H_
|
|
|
|
#define UDP2RAW_LOG_MYLOG_H_
|
2017-07-24 21:18:58 +08:00
|
|
|
|
2017-08-22 11:00:44 -05:00
|
|
|
|
2017-09-10 11:31:55 -05:00
|
|
|
#include "common.h"
|
2017-07-24 21:18:58 +08:00
|
|
|
|
2017-09-24 03:14:08 -05:00
|
|
|
|
2017-07-24 21:18:58 +08:00
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
#define RED "\x1B[31m"
|
|
|
|
#define GRN "\x1B[32m"
|
|
|
|
#define YEL "\x1B[33m"
|
|
|
|
#define BLU "\x1B[34m"
|
|
|
|
#define MAG "\x1B[35m"
|
|
|
|
#define CYN "\x1B[36m"
|
|
|
|
#define WHT "\x1B[37m"
|
|
|
|
#define RESET "\x1B[0m"
|
|
|
|
|
2017-07-25 01:54:09 +08:00
|
|
|
|
2017-07-26 06:29:40 +08:00
|
|
|
const int log_never=0;
|
2017-07-25 01:54:09 +08:00
|
|
|
const int log_fatal=1;
|
|
|
|
const int log_error=2;
|
|
|
|
const int log_warn=3;
|
|
|
|
const int log_info=4;
|
|
|
|
const int log_debug=5;
|
|
|
|
const int log_trace=6;
|
2017-07-26 08:51:05 +08:00
|
|
|
const int log_end=7;
|
|
|
|
|
|
|
|
const char log_text[][20]={"NEVER","FATAL","ERROR","WARN","INFO","DEBUG","TRACE",""};
|
2017-07-28 23:24:49 +08:00
|
|
|
const char log_color[][20]={RED,RED,RED,YEL,GRN,MAG,""};
|
2017-07-25 01:54:09 +08:00
|
|
|
|
|
|
|
extern int log_level;
|
2017-07-26 06:29:40 +08:00
|
|
|
extern int enable_log_position;
|
|
|
|
extern int enable_log_color;
|
2017-07-24 21:18:58 +08:00
|
|
|
|
|
|
|
|
2017-08-04 17:12:23 +08:00
|
|
|
#ifdef MY_DEBUG
|
|
|
|
#define mylog(__first_argu__dummy_abcde__,...) printf(__VA_ARGS__)
|
|
|
|
|
|
|
|
#else
|
2017-07-26 06:29:40 +08:00
|
|
|
#define mylog(...) log0(__FILE__,__FUNCTION__,__LINE__,__VA_ARGS__)
|
2017-08-04 17:12:23 +08:00
|
|
|
#endif
|
2017-07-24 21:18:58 +08:00
|
|
|
|
2017-08-04 03:29:53 +08:00
|
|
|
|
2017-08-04 04:22:16 +08:00
|
|
|
//#define mylog(__first_argu__dummy_abcde__,...) {;}
|
|
|
|
|
2017-07-25 00:04:49 +08:00
|
|
|
void log0(const char * file,const char * function,int line,int level,const char* str, ...);
|
2017-07-24 21:18:58 +08:00
|
|
|
|
2017-07-26 06:29:40 +08:00
|
|
|
void log_bare(int level,const char* str, ...);
|
|
|
|
|
2017-07-24 21:18:58 +08:00
|
|
|
|
|
|
|
#endif
|