core-lightning/lightningd/log_status.c
trueptolemy 96135dab5e log: add 'warning' notification when log
- Related Changes for `warning` notification

Add a `bool` type parameter in `log_()` and `lov()`, this `bool` flag
 indicates if we should call `warning` notifier.

1) The process of copying `log_book` of every peer to the `log_book` of
`ld` is usually included in `log_()` and `lov()`, and it may lead to
repeated `warning` notification. So a `bool`, which explicitly indicates
if the `warning` notification is disabled during this call, is necessary
.
2) The `LOG_INFO` and `LOG_DEBUG` level don't need to call
warning, so set that `bool` paramater as `FALSE` for these log level and
only set it as `TRUE` for `LOG_UNUAUSL`/`LOG_BROKEN`. As for `LOG_IO`,
it use `log_io()` to log, so we needn't think about notifier for it.
2019-06-07 01:23:51 +00:00

26 lines
676 B
C

#include <common/gen_status_wire.h>
#include <lightningd/log_status.h>
bool log_status_msg(struct log *log, const u8 *msg)
{
char *entry, *who;
u8 *data;
enum log_level level;
bool call_notifier;
if (fromwire_status_log(msg, msg, &level, &entry)) {
if (level != LOG_IO_IN && level != LOG_IO_OUT) {
call_notifier = (level == LOG_BROKEN ||
level == LOG_UNUSUAL)? true : false;
log_(log, level, call_notifier, "%s", entry);
return true;
}
} else if (fromwire_status_io(msg, msg, &level, &who, &data)) {
if (level == LOG_IO_IN || level == LOG_IO_OUT) {
log_io(log, level, who, data, tal_count(data));
return true;
}
}
return false;
}