mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
plugins/renepay: Add infra for per-flow notes.
And set logging levels. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
a28e0afaef
commit
4196f97571
3 changed files with 33 additions and 6 deletions
|
@ -31,7 +31,7 @@ void _debug_exec_branch(const char* fname,const char* fun, int lineno);
|
|||
{_debug_info(MYLOG,__VA_ARGS__); abort();}
|
||||
|
||||
#define debug_paynote(p,...) \
|
||||
{payment_note(p,__VA_ARGS__);_debug_info(MYLOG,__VA_ARGS__);}
|
||||
{payment_note(p,LOG_INFORM,__VA_ARGS__);_debug_info(MYLOG,__VA_ARGS__);}
|
||||
|
||||
#else
|
||||
/* Debugging information goes either to payment notes or to lightningd log. */
|
||||
|
@ -43,7 +43,7 @@ void _debug_exec_branch(const char* fname,const char* fun, int lineno);
|
|||
plugin_err(pay_plugin->plugin,__VA_ARGS__)
|
||||
|
||||
#define debug_paynote(p,...) \
|
||||
payment_note(p,__VA_ARGS__);
|
||||
payment_note(p,LOG_INFORM,__VA_ARGS__);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -98,7 +98,9 @@ struct amount_msat payment_fees(const struct payment *p)
|
|||
return fees;
|
||||
}
|
||||
|
||||
void payment_note(struct payment *p, const char *fmt, ...)
|
||||
void payment_note(struct payment *p,
|
||||
enum log_level lvl,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
const char *str;
|
||||
|
@ -107,10 +109,27 @@ void payment_note(struct payment *p, const char *fmt, ...)
|
|||
str = tal_vfmt(p->paynotes, fmt, ap);
|
||||
va_end(ap);
|
||||
tal_arr_expand(&p->paynotes, str);
|
||||
debug_info("%s",str);
|
||||
/* Log at debug, unless it's weird... */
|
||||
plugin_log(pay_plugin->plugin,
|
||||
lvl < LOG_UNUSUAL ? LOG_DBG : lvl, "%s", str);
|
||||
|
||||
if (p->cmd)
|
||||
plugin_notify_message(p->cmd, LOG_INFORM, "%s", str);
|
||||
plugin_notify_message(p->cmd, lvl, "%s", str);
|
||||
}
|
||||
|
||||
void payflow_note(struct pay_flow *pf,
|
||||
enum log_level lvl,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
const char *str;
|
||||
|
||||
va_start(ap, fmt);
|
||||
str = tal_vfmt(tmpctx, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
payment_note(pf->payment, lvl, " Flow %"PRIu64": %s",
|
||||
pf->key.partid, str);
|
||||
}
|
||||
|
||||
void payment_assert_delivering_incomplete(const struct payment *p)
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <common/gossmap.h>
|
||||
#include <plugins/libplugin.h>
|
||||
|
||||
struct pay_flow;
|
||||
|
||||
enum payment_status {
|
||||
PAYMENT_PENDING, PAYMENT_SUCCESS, PAYMENT_FAIL
|
||||
};
|
||||
|
@ -140,7 +142,13 @@ struct amount_msat payment_delivered(const struct payment *p);
|
|||
struct amount_msat payment_amount(const struct payment *p);
|
||||
struct amount_msat payment_fees(const struct payment *p);
|
||||
|
||||
void payment_note(struct payment *p, const char *fmt, ...);
|
||||
/* These log at LOG_DBG, append to notes, and send command notification */
|
||||
void payment_note(struct payment *p,
|
||||
enum log_level lvl,
|
||||
const char *fmt, ...);
|
||||
void payflow_note(struct pay_flow *pf,
|
||||
enum log_level lvl,
|
||||
const char *fmt, ...);
|
||||
void payment_assert_delivering_incomplete(const struct payment *p);
|
||||
void payment_assert_delivering_all(const struct payment *p);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue