#include <stdio.h>
#include <stdlib.h>
#define global_debug 2
#define global_progname "MYLOG"
enum
{
ERROR,
WARN,
INFO,
DEBUG,
};
#define debug(OUT, STR, ARGS...) \
if (global_debug >= DEBUG) \
fprintf(stdout, "%s - DEBUG: [%lli] ", global_progname, (long long)getpid()),\
fprintf(OUT, STR, ##ARGS), fflush(OUT)
#define info(OUT, STR, ARGS...) \
if (global_debug >= INFO) \
fprintf(stdout, "%s - INFO: [%lli] ", global_progname, (long long)getpid()),\
fprintf(OUT, STR, ##ARGS), fflush(OUT)
#define warn(OUT, STR, ARGS...) \
if (global_debug >= WARN) \
fprintf(stdout, "%s - WARN: [%lli] (line: %d) ", global_progname, (long long)getpid(),__LINE__ ),\
fprintf(OUT, STR, ##ARGS), fflush(OUT)
#define error(OUT, STR, ARGS...) \
if (global_debug >= ERROR) \
fprintf(stdout, "%s - ERROR: [%lli](line: %d) ", global_progname, (long long)getpid(), __LINE__),\
版权声明:本文为j123kaishichufa原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。