diff --git a/src/bip.c b/src/bip.c index ff30180..c9a96de 100644 --- a/src/bip.c +++ b/src/bip.c @@ -160,7 +160,7 @@ void conf_die(bip_t *bip, char *fmt, ...) error = bip_realloc(error, size); } va_start(ap, fmt); - _mylog(LOG_ERROR, fmt, ap); + mylog(LOG_ERROR, fmt, ap); va_end(ap); } diff --git a/src/util.c b/src/util.c index fe64741..c34bfe6 100644 --- a/src/util.c +++ b/src/util.c @@ -34,6 +34,7 @@ extern int conf_log_system; extern int errno; #pragma GCC diagnostic pop extern FILE *conf_global_log_file; +void _mylog(int level, int with_timestamp, char *fmt, va_list ap); void memory_fatal(void) { @@ -260,7 +261,7 @@ char *checkmode2text(int v) } #endif -void _mylog(int level, char *fmt, va_list ap) +void _mylog(int level, int with_timestamp, char *fmt, va_list ap) { char *prefix; @@ -294,7 +295,11 @@ void _mylog(int level, char *fmt, va_list ap) break; } - fprintf(conf_global_log_file, "%s %s", timestamp(), prefix); + if (with_timestamp) + fprintf(conf_global_log_file, "%s %s", timestamp(), prefix); + else + fprintf(conf_global_log_file, "%s", prefix); + vfprintf(conf_global_log_file, fmt, ap); fprintf(conf_global_log_file, "\n"); #ifdef DEBUG @@ -307,7 +312,16 @@ void mylog(int level, char *fmt, ...) va_list ap; va_start(ap, fmt); - _mylog(level, fmt, ap); + _mylog(level, 1, fmt, ap); + va_end(ap); +} + +void mylog_nots(int level, char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + _mylog(level, 0, fmt, ap); va_end(ap); } @@ -330,7 +344,22 @@ void fatal(char *fmt, ...) va_list ap; va_start(ap, fmt); - _mylog(LOG_FATAL, fmt, ap); + _mylog(LOG_FATAL, 1, fmt, ap); + va_end(ap); + +#ifdef HAVE_BACKTRACE + dump_trace(); +#endif + + exit(200); +} + +void fatal_nots(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + _mylog(LOG_FATAL, 0, fmt, ap); va_end(ap); #ifdef HAVE_BACKTRACE diff --git a/src/util.h b/src/util.h index 8db79f4..311f16a 100644 --- a/src/util.h +++ b/src/util.h @@ -32,8 +32,9 @@ #define HASH_DEFAULT 0 void mylog(int level, char *fmt, ...); -void _mylog(int level, char *fmt, va_list ap); +void mylog_nots(int level, char *fmt, ...); void fatal(char *fmt, ...); +void fatal_nots(char *fmt, ...); char *timestamp(void); struct hash_item;