|
|
@ -28,74 +28,67 @@ extern int opt_log_level; |
|
|
|
|
|
|
|
|
|
|
|
extern int opt_log_show_date; |
|
|
|
extern int opt_log_show_date; |
|
|
|
|
|
|
|
|
|
|
|
#define LOGBUFSIZ 256 |
|
|
|
#define LOGBUFSIZ 512 |
|
|
|
|
|
|
|
|
|
|
|
void applog(int prio, const char* fmt, ...); |
|
|
|
void applog(int prio, const char* fmt, ...); |
|
|
|
|
|
|
|
void applogsiz(int prio, int size, const char* fmt, ...); |
|
|
|
|
|
|
|
void vapplogsiz(int prio, int size, const char* fmt, va_list args); |
|
|
|
|
|
|
|
|
|
|
|
extern void _applog(int prio, const char *str, bool force); |
|
|
|
extern void _applog(int prio, const char *str, bool force); |
|
|
|
|
|
|
|
|
|
|
|
#define IN_FMT_FFL " in %s %s():%d" |
|
|
|
#define IN_FMT_FFL " in %s %s():%d" |
|
|
|
|
|
|
|
|
|
|
|
#define applogsiz(prio, _SIZ, fmt, ...) do { \ |
|
|
|
|
|
|
|
if (opt_debug || prio != LOG_DEBUG) { \ |
|
|
|
|
|
|
|
if (use_syslog || opt_log_output || prio <= opt_log_level) { \ |
|
|
|
|
|
|
|
char tmp42[_SIZ]; \ |
|
|
|
|
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ |
|
|
|
|
|
|
|
_applog(prio, tmp42, false); \ |
|
|
|
|
|
|
|
} \ |
|
|
|
|
|
|
|
} \ |
|
|
|
|
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define forcelog(prio, fmt, ...) do { \ |
|
|
|
#define forcelog(prio, fmt, ...) do { \ |
|
|
|
if (opt_debug || prio != LOG_DEBUG) { \ |
|
|
|
if (opt_debug || prio != LOG_DEBUG) { \ |
|
|
|
if (use_syslog || opt_log_output || prio <= opt_log_level) { \ |
|
|
|
if (use_syslog || opt_log_output || prio <= opt_log_level) { \ |
|
|
|
char tmp42[LOGBUFSIZ]; \ |
|
|
|
char tmp42[LOGBUFSIZ]; \ |
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ |
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ |
|
|
|
_applog(prio, tmp42, true); \ |
|
|
|
_applog(prio, tmp42, true); \ |
|
|
|
} \ |
|
|
|
} \ |
|
|
|
} \ |
|
|
|
} \ |
|
|
|
} while (0) |
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
#define quit(status, fmt, ...) do { \ |
|
|
|
#define quit(status, fmt, ...) do { \ |
|
|
|
if (fmt) { \ |
|
|
|
if (fmt) { \ |
|
|
|
char tmp42[LOGBUFSIZ]; \ |
|
|
|
char tmp42[LOGBUFSIZ]; \ |
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ |
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ |
|
|
|
_applog(LOG_ERR, tmp42, true); \ |
|
|
|
_applog(LOG_ERR, tmp42, true); \ |
|
|
|
} \ |
|
|
|
} \ |
|
|
|
_quit(status); \ |
|
|
|
_quit(status); \ |
|
|
|
} while (0) |
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
#define quithere(status, fmt, ...) do { \ |
|
|
|
#define quithere(status, fmt, ...) do { \ |
|
|
|
if (fmt) { \ |
|
|
|
if (fmt) { \ |
|
|
|
char tmp42[LOGBUFSIZ]; \ |
|
|
|
char tmp42[LOGBUFSIZ]; \ |
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt IN_FMT_FFL, \ |
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt IN_FMT_FFL, \ |
|
|
|
##__VA_ARGS__, __FILE__, __func__, __LINE__); \ |
|
|
|
##__VA_ARGS__, __FILE__, __func__, __LINE__); \ |
|
|
|
_applog(LOG_ERR, tmp42, true); \ |
|
|
|
_applog(LOG_ERR, tmp42, true); \ |
|
|
|
} \ |
|
|
|
} \ |
|
|
|
_quit(status); \ |
|
|
|
_quit(status); \ |
|
|
|
} while (0) |
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
#define quitfrom(status, _file, _func, _line, fmt, ...) do { \ |
|
|
|
#define quitfrom(status, _file, _func, _line, fmt, ...) do { \ |
|
|
|
if (fmt) { \ |
|
|
|
if (fmt) { \ |
|
|
|
char tmp42[LOGBUFSIZ]; \ |
|
|
|
char tmp42[LOGBUFSIZ]; \ |
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt IN_FMT_FFL, \ |
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt IN_FMT_FFL, \ |
|
|
|
##__VA_ARGS__, _file, _func, _line); \ |
|
|
|
##__VA_ARGS__, _file, _func, _line); \ |
|
|
|
_applog(LOG_ERR, tmp42, true); \ |
|
|
|
_applog(LOG_ERR, tmp42, true); \ |
|
|
|
} \ |
|
|
|
} \ |
|
|
|
_quit(status); \ |
|
|
|
_quit(status); \ |
|
|
|
} while (0) |
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CURSES |
|
|
|
#ifdef HAVE_CURSES |
|
|
|
|
|
|
|
|
|
|
|
#define wlog(fmt, ...) do { \ |
|
|
|
#define wlog(fmt, ...) do { \ |
|
|
|
char tmp42[LOGBUFSIZ]; \ |
|
|
|
char tmp42[LOGBUFSIZ]; \ |
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ |
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ |
|
|
|
_wlog(tmp42); \ |
|
|
|
_wlog(tmp42); \ |
|
|
|
} while (0) |
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
#define wlogprint(fmt, ...) do { \ |
|
|
|
#define wlogprint(fmt, ...) do { \ |
|
|
|
char tmp42[LOGBUFSIZ]; \ |
|
|
|
char tmp42[LOGBUFSIZ]; \ |
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ |
|
|
|
snprintf(tmp42, sizeof(tmp42), fmt, ##__VA_ARGS__); \ |
|
|
|
_wlogprint(tmp42); \ |
|
|
|
_wlogprint(tmp42); \ |
|
|
|
} while (0) |
|
|
|
} while (0) |
|
|
|
|
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|