mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
db: decouple fatal reliance, have as impl defined function
`fatal` is defined in lightningd and has logfile dependencies etc. Make it more generic by allowing declaration in the use file (wallet.c)
This commit is contained in:
@@ -809,22 +809,25 @@ void log_backtrace_exit(void)
|
||||
}
|
||||
}
|
||||
|
||||
void fatal_vfmt(const char *fmt, va_list ap)
|
||||
{
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (!crashlog)
|
||||
exit(1);
|
||||
|
||||
logv(crashlog, LOG_BROKEN, NULL, true, fmt, ap);
|
||||
abort();
|
||||
}
|
||||
|
||||
void fatal(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
fprintf(stderr, "\n");
|
||||
fatal_vfmt(fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (!crashlog)
|
||||
exit(1);
|
||||
|
||||
va_start(ap, fmt);
|
||||
logv(crashlog, LOG_BROKEN, NULL, true, fmt, ap);
|
||||
va_end(ap);
|
||||
abort();
|
||||
}
|
||||
|
||||
struct log_info {
|
||||
|
||||
@@ -53,6 +53,7 @@ char *arg_log_to_file(const char *arg, struct lightningd *ld);
|
||||
/* Once this is set, we dump fatal with a backtrace to this log */
|
||||
extern struct log *crashlog;
|
||||
void NORETURN PRINTF_FMT(1,2) fatal(const char *fmt, ...);
|
||||
void NORETURN fatal_vfmt(const char *fmt, va_list ap);
|
||||
|
||||
void log_backtrace_print(const char *fmt, ...);
|
||||
void log_backtrace_exit(void);
|
||||
|
||||
Reference in New Issue
Block a user