WIP, more context changes
[imager.git] / log.h
1 #ifndef _LOG_H_
2 #define _LOG_H_
3
4 #include <stdio.h>
5 #include <stdarg.h>
6 #include <time.h>
7 #include "imdatatypes.h"
8 /* 
9    input:  name of file to log too
10    input:  onoff, 0 means no logging
11    global: creates a global variable FILE* lg_file
12 */
13
14 int im_init_log(pIMCTX, const char *name, int onoff );
15 #define i_init_log(name, onoff) im_init_log(aIMCTX, name, onoff)
16 void i_fatal ( int exitcode,const char *fmt, ... );
17 void im_lhead ( pIMCTX, const char *file, int line  );
18 void i_lhead ( const char *file, int line  );
19 void i_loog(int level,const char *msg, ... ) I_FORMAT_ATTR(2,3);
20 void im_loog(pIMCTX, int level,const char *msg, ... ) I_FORMAT_ATTR(3,4);
21
22 /*
23 =item mm_log((level, format, ...))
24 =category Logging
25
26 This is the main entry point to logging. Note that the extra set of
27 parentheses are required due to limitations in C89 macros.
28
29 This will format a string with the current file and line number to the
30 log file if logging is enabled.
31
32 =cut
33 */
34
35 #ifdef IMAGER_LOG
36 #define mm_log(x) { i_lhead(__FILE__,__LINE__); i_loog x; } 
37 #define im_log(x) { im_lhead(aIMCTX, __FILE__,__LINE__); im_loog x; } 
38 #else
39 #define mm_log(x)
40 #define im_log(x)
41 #endif
42
43
44 #endif /* _LOG_H_ */