2018-02-08 02:25:12 +01:00
|
|
|
#include <common/gen_status_wire.h>
|
2018-02-05 05:09:27 +01:00
|
|
|
#include <lightningd/log_status.h>
|
|
|
|
|
2019-11-17 12:41:33 +01:00
|
|
|
bool log_status_msg(struct log *log,
|
|
|
|
const struct node_id *node_id,
|
|
|
|
const u8 *msg)
|
2018-02-05 05:09:27 +01:00
|
|
|
{
|
2018-05-10 01:18:24 +02:00
|
|
|
char *entry, *who;
|
2018-02-08 02:25:12 +01:00
|
|
|
u8 *data;
|
2019-11-17 12:42:33 +01:00
|
|
|
struct node_id *suggested_node_id;
|
2018-02-08 02:25:12 +01:00
|
|
|
enum log_level level;
|
2019-06-06 10:26:42 +02:00
|
|
|
bool call_notifier;
|
2018-02-05 05:09:27 +01:00
|
|
|
|
2019-11-17 12:42:33 +01:00
|
|
|
if (fromwire_status_log(msg, msg, &level, &suggested_node_id, &entry)) {
|
|
|
|
/* If there's not already a node_id (global subdirs), they can
|
|
|
|
* set it */
|
|
|
|
if (!node_id)
|
|
|
|
node_id = suggested_node_id;
|
2018-02-08 02:25:12 +01:00
|
|
|
if (level != LOG_IO_IN && level != LOG_IO_OUT) {
|
2019-06-06 10:26:42 +02:00
|
|
|
call_notifier = (level == LOG_BROKEN ||
|
|
|
|
level == LOG_UNUSUAL)? true : false;
|
2019-11-17 12:41:33 +01:00
|
|
|
log_(log, level, node_id, call_notifier, "%s", entry);
|
2018-02-08 02:25:12 +01:00
|
|
|
return true;
|
|
|
|
}
|
2019-11-17 12:42:33 +01:00
|
|
|
} else if (fromwire_status_io(msg, msg, &level, &suggested_node_id,
|
|
|
|
&who, &data)) {
|
2018-02-08 02:25:12 +01:00
|
|
|
if (level == LOG_IO_IN || level == LOG_IO_OUT) {
|
2019-11-17 12:42:33 +01:00
|
|
|
if (!node_id)
|
|
|
|
node_id = suggested_node_id;
|
2019-11-17 12:41:33 +01:00
|
|
|
log_io(log, level, node_id, who, data, tal_count(data));
|
2018-02-08 02:25:12 +01:00
|
|
|
return true;
|
2018-02-05 05:09:27 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-08 02:25:12 +01:00
|
|
|
return false;
|
2018-02-05 05:09:27 +01:00
|
|
|
}
|