mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-24 01:24:26 +01:00
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.
This commit is contained in:
committed by
Rusty Russell
parent
231703cc7f
commit
96135dab5e
@@ -196,6 +196,7 @@ static void plugin_log_handle(struct plugin *plugin, const jsmntok_t *paramstok)
|
||||
{
|
||||
const jsmntok_t *msgtok, *leveltok;
|
||||
enum log_level level;
|
||||
bool call_notifier;
|
||||
msgtok = json_get_member(plugin->buffer, paramstok, "message");
|
||||
leveltok = json_get_member(plugin->buffer, paramstok, "level");
|
||||
|
||||
@@ -222,7 +223,8 @@ static void plugin_log_handle(struct plugin *plugin, const jsmntok_t *paramstok)
|
||||
return;
|
||||
}
|
||||
|
||||
log_(plugin->log, level, "%.*s", msgtok->end - msgtok->start,
|
||||
call_notifier = (level == LOG_BROKEN || level == LOG_UNUSUAL)? true : false;
|
||||
log_(plugin->log, level, call_notifier, "%.*s", msgtok->end - msgtok->start,
|
||||
plugin->buffer + msgtok->start);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user