Revision 6575ae37 ml_log.h
ml_log.h | ||
---|---|---|
4 | 4 |
#include <stdlib.h> |
5 | 5 |
#include <stdio.h> |
6 | 6 |
|
7 |
//#include "grapes_log.h"
|
|
7 |
extern int ml_log_level;
|
|
8 | 8 |
|
9 |
#ifndef _GRAPES_LOG_H
|
|
9 |
extern void setLogLevel(int ll);
|
|
10 | 10 |
|
11 |
#define DPRINT(format, ... ) {struct timeval tnow; gettimeofday(&tnow,NULL); fprintf(stderr, "%ld.%03ld "format, tnow.tv_sec, tnow.tv_usec/1000, ##__VA_ARGS__ );}
|
|
11 |
#define DPRINT(ll, format, ... ) {struct timeval tnow; if(ll <= ml_log_level) {gettimeofday(&tnow,NULL); fprintf(stderr, "%ld.%03ld "format, tnow.tv_sec, tnow.tv_usec/1000, ##__VA_ARGS__ );fprintf(stderr,format[strlen(format)-1] == '\n'?"":"\n"); fflush(stderr);}}
|
|
12 | 12 |
|
13 |
#define debug(format, ... ) //DPRINT(format, ##__VA_ARGS__ )
|
|
13 |
#define debug(format, ... ) DPRINT(4 ,format, ##__VA_ARGS__ )
|
|
14 | 14 |
/** Convenience macro to log LOG_INFO messages */ |
15 |
#define info(format, ... ) DPRINT(format, ##__VA_ARGS__ ) |
|
15 |
#define info(format, ... ) DPRINT(3, format, ##__VA_ARGS__ )
|
|
16 | 16 |
/** Convenience macro to log LOG_WARN messages */ |
17 |
#define warn(format, ... ) DPRINT(format, ##__VA_ARGS__ ) |
|
17 |
#define warn(format, ... ) DPRINT(2, format, ##__VA_ARGS__ )
|
|
18 | 18 |
/** Convenience macro to log LOG_ERROR messages */ |
19 |
#define error(format, ... ) DPRINT(format, ##__VA_ARGS__ ) |
|
19 |
#define error(format, ... ) DPRINT(1, format, ##__VA_ARGS__ )
|
|
20 | 20 |
/** Convenience macro to log LOG_CRITICAL messages and crash the program */ |
21 |
#define fatal(format, ... ) { DPRINT(format, ##__VA_ARGS__ ); exit(-1); } |
|
21 |
#define fatal(format, ... ) { DPRINT(0, format, ##__VA_ARGS__ ); exit(-1); }
|
|
22 | 22 |
|
23 | 23 |
#endif |
24 |
#endif |
Also available in: Unified diff