-
-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wallet logger interface, more (responsive) logs #1516
base: master
Are you sure you want to change the base?
Conversation
6b2a906
to
6161c48
Compare
Current status: 2cb3342
TODO:
|
2cb3342
to
7a24ffb
Compare
How "rich log" looks so far: 2024-11-05.04-39-23.mp4(not really rich yet since it's just text, no links to anywhere) I am not super happy with |
* remove unused logNav class * rename classes
* the code assignment was broken anyway * we already log withdrawal errors using .catch on payViaPaymentRequest
Current status (a610b93): 2024-11-06.03-10-33.mp4I believe there is a bug where we don't store the invoice description since it's empty in the database even though the stored bolt11 does contain a description (see missing invoice description in last receiver log). |
// server implementation of wallet logger interface on client | ||
const log = (level) => async (message, context = {}) => { | ||
try { | ||
await models.walletLog.create({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no console.log
here since I think wallets logs inside the server logs would be more noise than signal
testCreateInvoice: | ||
walletDef.testCreateInvoice && validateLightning && canReceive({ def: walletDef, config: data }) | ||
? (data) => walletDef.testCreateInvoice(data, { me, models }) | ||
? (data) => walletDef.testCreateInvoice(data, { logger, me, models }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we pass logger
to testCreateInvoice
of the wallets but we only use the logger for NWC. So far, I saw no need to add wallet-specific logging to the other wallets.
export function assertContentTypeJson (res) { | ||
const contentType = res.headers.get('content-type') | ||
if (!contentType || !contentType.includes('application/json')) { | ||
throw new Error(`POST ${res.url}: ${res.status} ${res.statusText}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no more gigantic error messages about how we couldn't parse the HTML body as JSON when a reverse proxy throws a gateway timeout
@@ -26,7 +26,7 @@ async function disconnect (lnc, logger) { | |||
}, 50) | |||
logger.info('disconnected') | |||
} catch (err) { | |||
logger.error('failed to disconnect from lnc', err) | |||
logger.error('failed to disconnect from lnc: ' + err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger
no longer supports a variable number of arguments because second argument is now context
@@ -294,7 +292,7 @@ export async function checkWithdrawal ({ data: { hash, withdrawal, invoice }, bo | |||
|
|||
const fee = Number(wdrwl.payment.fee_mtokens) | |||
const paid = Number(wdrwl.payment.mtokens) - fee | |||
const [{ confirm_withdrawl: code }] = await serialize([ | |||
const [[{ confirm_withdrawl: code }]] = await serialize([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for some reason the return type changed at some point
const message = `autowithdrawal of ${ | ||
numWithUnits(msatsToSats(paid), { abbreviate: false })} with ${ | ||
numWithUnits(msatsToSats(fee), { abbreviate: false })} as fee` | ||
await addWalletLog({ wallet: dbWdrwl.wallet, level: 'SUCCESS', message }, { models }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this because we log success/errors using .then
and .catch
on payViaPaymentRequest
Description
Close #1380
based on #1510, #1511, #1515
TODO:
addWalletLog
with logger interfaceincoming payments; amount of payments; especially info around errors
Video
Current status (a610b93):
2024-11-06.03-10-33.mp4
Additional Context
we currently only log
wallet attached
/wallet details updated
andwallet enabled
/wallet disabled
for receives so if you only attach spending credentials, there's no such log. ideally, we would only log these once, no matter if send and/or recv was attached. but how without creating a mess? previously, we logged them separately but that was noisy.I believe there is a bug where we don't store the invoice description of unwrapped invoices since it's empty in the database even though the stored bolt11 does contain a description (see missing invoice description in last receiver log in video).
Checklist
Are your changes backwards compatible? Please answer below:
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
For frontend changes: Tested on mobile? Please answer below:
Did you introduce any new environment variables? If so, call them out explicitly here: