mirror of
https://github.com/getAlby/lndhub.go.git
synced 2026-01-06 06:26:15 +01:00
json logging
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/getAlby/lndhub.go/lnd"
|
||||
"github.com/getsentry/sentry-go"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/gommon/log"
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
)
|
||||
|
||||
@@ -83,7 +84,13 @@ func (controller *KeySendController) KeySend(c echo.Context) error {
|
||||
|
||||
ok, err := controller.svc.BalanceCheck(c.Request().Context(), lnPayReq, userID)
|
||||
if err != nil {
|
||||
c.Logger().Errorf("Failed to check balance user_id: %v error: %v", userID, err)
|
||||
c.Logger().Errorj(
|
||||
log.JSON{
|
||||
"message": "failed to check balance",
|
||||
"error": err,
|
||||
"lndhub_user_id": userID,
|
||||
},
|
||||
)
|
||||
return c.JSON(http.StatusBadRequest, responses.BadArgumentsError)
|
||||
}
|
||||
if !ok {
|
||||
@@ -92,7 +99,13 @@ func (controller *KeySendController) KeySend(c echo.Context) error {
|
||||
}
|
||||
invoice, err := controller.svc.AddOutgoingInvoice(c.Request().Context(), userID, "", lnPayReq)
|
||||
if err != nil {
|
||||
c.Logger().Errorf("Error saving invoice user_id: %v error: %v", userID, err)
|
||||
c.Logger().Errorj(
|
||||
log.JSON{
|
||||
"message": "failed to add invoice",
|
||||
"error": err,
|
||||
"lndhub_user_id": userID,
|
||||
},
|
||||
)
|
||||
return c.JSON(http.StatusBadRequest, responses.BadArgumentsError)
|
||||
}
|
||||
if _, err := hex.DecodeString(invoice.DestinationPubkeyHex); err != nil || len(invoice.DestinationPubkeyHex) != common.DestinationPubkeyHexSize {
|
||||
@@ -103,7 +116,13 @@ func (controller *KeySendController) KeySend(c echo.Context) error {
|
||||
for key, value := range reqBody.CustomRecords {
|
||||
intKey, err := strconv.Atoi(key)
|
||||
if err != nil {
|
||||
c.Logger().Errorf("Invalid custom records user_id: %v error: %v", userID, err)
|
||||
c.Logger().Errorj(
|
||||
log.JSON{
|
||||
"message": "invalid custom records",
|
||||
"error": err,
|
||||
"lndhub_user_id": userID,
|
||||
},
|
||||
)
|
||||
return c.JSON(http.StatusBadRequest, responses.BadArgumentsError)
|
||||
}
|
||||
invoice.DestinationCustomRecords[uint64(intKey)] = []byte(value)
|
||||
|
||||
Reference in New Issue
Block a user