ft/adds logs to all internal errors
This commit is contained in:
parent
76b348f0ae
commit
2b2e4e6dc8
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
@ -30,6 +31,7 @@ func (server *Server) BlockSession(ctx context.Context, req *pb.BlockSessionRequ
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "session not found")
|
||||
}
|
||||
slog.Error("block_session (get)", slog.String("invoked_by", authPayload.Email), slog.String("session_id", req.GetSessionId()), slog.String("error", err.Error()))
|
||||
return nil, status.Errorf(codes.Internal, "failed to get session")
|
||||
}
|
||||
|
||||
@ -45,6 +47,7 @@ func (server *Server) BlockSession(ctx context.Context, req *pb.BlockSessionRequ
|
||||
|
||||
err = server.store.BlockSession(ctx, uid)
|
||||
if err != nil {
|
||||
slog.Error("block_session (db)", slog.String("invoked_by", authPayload.Email), slog.String("session_id", req.GetSessionId()), slog.String("error", err.Error()))
|
||||
return nil, status.Errorf(codes.Internal, "failed to block session")
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
db "github.com/itsscb/df/bff/db/sqlc"
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
@ -22,6 +23,7 @@ func (server *Server) CreateAccount(ctx context.Context, req *pb.CreateAccountRe
|
||||
|
||||
hashedPassword, err := util.HashPassword(req.GetPassword())
|
||||
if err != nil {
|
||||
slog.Error("create_account (hash_password)", slog.String("invoked_by", req.GetEmail()), slog.String("error", err.Error()))
|
||||
return nil, status.Errorf(codes.Internal, "failed to hash password: %s", err)
|
||||
}
|
||||
|
||||
@ -48,6 +50,7 @@ func (server *Server) CreateAccount(ctx context.Context, req *pb.CreateAccountRe
|
||||
|
||||
account, err := server.store.CreateAccountTx(ctx, arg)
|
||||
if err != nil {
|
||||
slog.Error("create_account (db)", slog.String("invoked_by", req.GetEmail()), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to create account")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
db "github.com/itsscb/df/bff/db/sqlc"
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
@ -29,6 +30,7 @@ func (server *Server) CreatePayment(ctx context.Context, req *pb.CreatePaymentRe
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("create_payment (get_account)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetAccountId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.NotFound, "failed to get account")
|
||||
}
|
||||
|
||||
@ -72,6 +74,7 @@ func (server *Server) CreatePayment(ctx context.Context, req *pb.CreatePaymentRe
|
||||
|
||||
payment, err := server.store.CreatePayment(ctx, arg)
|
||||
if err != nil {
|
||||
slog.Error("create_payment (db)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetAccountId())), slog.String("payment_category", req.GetPaymentCategory()), slog.String("error", err.Error()))
|
||||
return nil, status.Errorf(codes.Internal, "failed to create payment")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
db "github.com/itsscb/df/bff/db/sqlc"
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
@ -29,6 +31,7 @@ func (server *Server) CreatePerson(ctx context.Context, req *pb.CreatePersonRequ
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("create_person (get_account)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetAccountId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.NotFound, "failed to get account")
|
||||
}
|
||||
|
||||
@ -53,6 +56,7 @@ func (server *Server) CreatePerson(ctx context.Context, req *pb.CreatePersonRequ
|
||||
|
||||
person, err := server.store.CreatePersonTx(ctx, arg)
|
||||
if err != nil {
|
||||
slog.Error("create_person (db)", slog.String("invoked_by", authPayload.Email), slog.String("person", fmt.Sprintf("%s, %s", req.GetLastname(), req.GetFirstname())), slog.String("error", err.Error()))
|
||||
return nil, status.Errorf(codes.Internal, "failed to create person")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
@ -27,6 +28,7 @@ func (server *Server) DeletePayment(ctx context.Context, req *pb.DeletePaymentRe
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("delete_payment (get_account)", slog.String("invoked_by", authPayload.Email), slog.Int64("payment_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to get account")
|
||||
}
|
||||
|
||||
@ -41,6 +43,7 @@ func (server *Server) DeletePayment(ctx context.Context, req *pb.DeletePaymentRe
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "payment not found")
|
||||
}
|
||||
slog.Error("delete_payment (get_payment)", slog.String("invoked_by", authPayload.Email), slog.Int64("payment_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Errorf(codes.Internal, "failed to get payment")
|
||||
}
|
||||
|
||||
@ -52,7 +55,8 @@ func (server *Server) DeletePayment(ctx context.Context, req *pb.DeletePaymentRe
|
||||
|
||||
err = server.store.DeletePayment(ctx, req.GetId())
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to block payment")
|
||||
slog.Error("delete_payment (db)", slog.String("invoked_by", authPayload.Email), slog.Int64("payment_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Errorf(codes.Internal, "failed to delete payment")
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
@ -27,6 +28,7 @@ func (server *Server) DeletePerson(ctx context.Context, req *pb.DeletePersonRequ
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("delete_person (get_account)", slog.String("invoked_by", authPayload.Email), slog.Int64("person_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to get account")
|
||||
}
|
||||
|
||||
@ -41,6 +43,7 @@ func (server *Server) DeletePerson(ctx context.Context, req *pb.DeletePersonRequ
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "person not found")
|
||||
}
|
||||
slog.Error("delete_person (get_person)", slog.String("invoked_by", authPayload.Email), slog.Int64("person_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Errorf(codes.Internal, "failed to get person")
|
||||
}
|
||||
|
||||
@ -52,6 +55,7 @@ func (server *Server) DeletePerson(ctx context.Context, req *pb.DeletePersonRequ
|
||||
|
||||
err = server.store.DeletePersonTx(ctx, person.ID)
|
||||
if err != nil {
|
||||
slog.Error("delete_person (db)", slog.String("invoked_by", authPayload.Email), slog.Int64("person_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Errorf(codes.Internal, "failed to delete person")
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
@ -27,6 +28,7 @@ func (server *Server) GetAccount(ctx context.Context, req *pb.GetAccountRequest)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("get_account (db)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to get account")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
@ -27,6 +28,7 @@ func (server *Server) GetPayment(ctx context.Context, req *pb.GetPaymentRequest)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("get_payment (get_account)", slog.String("invoked_by", authPayload.Email), slog.Int64("payment_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to get account")
|
||||
}
|
||||
|
||||
@ -41,6 +43,7 @@ func (server *Server) GetPayment(ctx context.Context, req *pb.GetPaymentRequest)
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Error(codes.NotFound, "no payments found")
|
||||
}
|
||||
slog.Error("get_payment (db)", slog.String("invoked_by", authPayload.Email), slog.Int64("payment_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.NotFound, "failed to get payments")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
@ -27,6 +28,7 @@ func (server *Server) GetPerson(ctx context.Context, req *pb.GetPersonRequest) (
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("get_person (get_account)", slog.String("invoked_by", authPayload.Email), slog.Int64("person_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to get account")
|
||||
}
|
||||
|
||||
@ -41,6 +43,7 @@ func (server *Server) GetPerson(ctx context.Context, req *pb.GetPersonRequest) (
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Error(codes.NotFound, "no persons found")
|
||||
}
|
||||
slog.Error("get_person (get_person)", slog.String("invoked_by", authPayload.Email), slog.Int64("person_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.NotFound, "failed to get persons")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
db "github.com/itsscb/df/bff/db/sqlc"
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
@ -33,6 +34,7 @@ func (server *Server) ListAccounts(ctx context.Context, req *pb.ListAccountsRequ
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Error(codes.NotFound, "no accounts found")
|
||||
}
|
||||
slog.Error("list_accounts (db)", slog.String("invoked_by", authPayload.Email), slog.Int("page_id", int(req.GetPageId())), slog.Int("page_size", int(req.GetPageSize())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.NotFound, "failed to get accounts")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
@ -27,6 +28,7 @@ func (server *Server) ListPayments(ctx context.Context, req *pb.ListPaymentsRequ
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("list_payments (get_account)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetAccountId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to get account")
|
||||
}
|
||||
|
||||
@ -47,6 +49,7 @@ func (server *Server) ListPayments(ctx context.Context, req *pb.ListPaymentsRequ
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Error(codes.NotFound, "no payments found")
|
||||
}
|
||||
slog.Error("list_payments (db)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetAccountId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.NotFound, "failed to get payments")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
@ -27,6 +28,7 @@ func (server *Server) ListPersons(ctx context.Context, req *pb.ListPersonsReques
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("list_persons (get_account)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetAccountId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to get account")
|
||||
}
|
||||
|
||||
@ -47,6 +49,7 @@ func (server *Server) ListPersons(ctx context.Context, req *pb.ListPersonsReques
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Error(codes.NotFound, "no persons found")
|
||||
}
|
||||
slog.Error("list_persons (db)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetAccountId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.NotFound, "failed to get persons")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
@ -27,6 +28,7 @@ func (server *Server) ListReturnsLog(ctx context.Context, req *pb.ListReturnsLog
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("list_returns_log_by_person_id (get_account)", slog.String("invoked_by", authPayload.Email), slog.Int64("person_id", int64(req.GetPersonId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to get account")
|
||||
}
|
||||
|
||||
@ -47,6 +49,7 @@ func (server *Server) ListReturnsLog(ctx context.Context, req *pb.ListReturnsLog
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Error(codes.NotFound, "no returns_logs found")
|
||||
}
|
||||
slog.Error("list_returns_log_by_person_id (db)", slog.String("invoked_by", authPayload.Email), slog.Int64("person_id", int64(req.GetPersonId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.NotFound, "failed to get returns_logs")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
"google.golang.org/genproto/googleapis/rpc/errdetails"
|
||||
@ -27,6 +28,7 @@ func (server *Server) ListSessions(ctx context.Context, req *pb.ListSessionsRequ
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("list_sessions (get_account)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetAccountId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to get account")
|
||||
}
|
||||
|
||||
@ -47,6 +49,7 @@ func (server *Server) ListSessions(ctx context.Context, req *pb.ListSessionsRequ
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Error(codes.NotFound, "no accounts found")
|
||||
}
|
||||
slog.Error("list_sessions (db)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetAccountId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.NotFound, "failed to get accounts")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
db "github.com/itsscb/df/bff/db/sqlc"
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
@ -27,6 +28,7 @@ func (server *Server) Login(ctx context.Context, req *pb.LoginRequest) (*pb.Logi
|
||||
return nil, status.Error(codes.NotFound, "account not found")
|
||||
|
||||
}
|
||||
slog.Error("login (get_account)", slog.String("invoked_by", req.GetEmail()), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to get account")
|
||||
}
|
||||
|
||||
@ -37,6 +39,7 @@ func (server *Server) Login(ctx context.Context, req *pb.LoginRequest) (*pb.Logi
|
||||
|
||||
id, err := server.tokenMaker.NewTokenID()
|
||||
if err != nil {
|
||||
slog.Error("login (token_id)", slog.String("invoked_by", req.GetEmail()), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to create token id")
|
||||
}
|
||||
|
||||
@ -46,6 +49,7 @@ func (server *Server) Login(ctx context.Context, req *pb.LoginRequest) (*pb.Logi
|
||||
server.config.RefreshTokenDuration,
|
||||
)
|
||||
if err != nil {
|
||||
slog.Error("login (refresh_token)", slog.String("invoked_by", req.GetEmail()), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to create refresh token")
|
||||
|
||||
}
|
||||
@ -56,6 +60,7 @@ func (server *Server) Login(ctx context.Context, req *pb.LoginRequest) (*pb.Logi
|
||||
server.config.AccessTokenDuration,
|
||||
)
|
||||
if err != nil {
|
||||
slog.Error("login (access_token)", slog.String("invoked_by", req.GetEmail()), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to create access token")
|
||||
}
|
||||
|
||||
@ -71,6 +76,7 @@ func (server *Server) Login(ctx context.Context, req *pb.LoginRequest) (*pb.Logi
|
||||
ExpiresAt: refreshPayload.ExpiredAt,
|
||||
})
|
||||
if err != nil {
|
||||
slog.Error("login (db)", slog.String("invoked_by", req.GetEmail()), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to create session")
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
@ -31,6 +32,7 @@ func (server *Server) RefreshToken(ctx context.Context, req *pb.RefreshTokenRequ
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Error(codes.NotFound, "session not found")
|
||||
}
|
||||
slog.Error("refresh_token (get_account)", slog.String("invoked_by", refreshPayload.Email), slog.String("refresh_token", req.GetRefreshToken()), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "cannot find session")
|
||||
}
|
||||
|
||||
@ -54,6 +56,7 @@ func (server *Server) RefreshToken(ctx context.Context, req *pb.RefreshTokenRequ
|
||||
|
||||
id, err := server.tokenMaker.NewTokenID()
|
||||
if err != nil {
|
||||
slog.Error("refresh_token (token_id)", slog.String("invoked_by", refreshPayload.Email), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to create session token")
|
||||
}
|
||||
accessToken, accessPayload, err := server.tokenMaker.CreateToken(
|
||||
@ -62,6 +65,7 @@ func (server *Server) RefreshToken(ctx context.Context, req *pb.RefreshTokenRequ
|
||||
server.config.AccessTokenDuration,
|
||||
)
|
||||
if err != nil {
|
||||
slog.Error("refresh_token (access_token)", slog.String("invoked_by", refreshPayload.Email), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to create session token")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
db "github.com/itsscb/df/bff/db/sqlc"
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
@ -75,6 +76,7 @@ func (server *Server) UpdateAccount(ctx context.Context, req *pb.UpdateAccountRe
|
||||
if req.Password != nil {
|
||||
hashedPassword, err := util.HashPassword(req.GetPassword())
|
||||
if err != nil {
|
||||
slog.Error("update_account (hash_password)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to hash password")
|
||||
}
|
||||
|
||||
@ -86,6 +88,7 @@ func (server *Server) UpdateAccount(ctx context.Context, req *pb.UpdateAccountRe
|
||||
|
||||
account, err := server.store.UpdateAccountTx(ctx, arg)
|
||||
if err != nil {
|
||||
slog.Error("update_account (db)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to update account")
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"log/slog"
|
||||
|
||||
db "github.com/itsscb/df/bff/db/sqlc"
|
||||
"github.com/itsscb/df/bff/pb"
|
||||
@ -28,6 +29,7 @@ func (server *Server) UpdateAccountPrivacy(ctx context.Context, req *pb.UpdateAc
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("update_account_privacy (get_account)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Errorf(codes.Internal, "failed to get account")
|
||||
}
|
||||
|
||||
@ -46,6 +48,7 @@ func (server *Server) UpdateAccountPrivacy(ctx context.Context, req *pb.UpdateAc
|
||||
|
||||
account, err = server.store.UpdateAccountPrivacyTx(ctx, arg)
|
||||
if err != nil {
|
||||
slog.Error("update_account_privacy (db)", slog.String("invoked_by", authPayload.Email), slog.Int64("account_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to update account privacy")
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ func (server *Server) UpdatePayment(ctx context.Context, req *pb.UpdatePaymentRe
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "account not found")
|
||||
}
|
||||
slog.Error("update_payment (get_account)", slog.String("invoked_by", authPayload.Email), slog.Int64("payment_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to get account")
|
||||
}
|
||||
|
||||
@ -44,6 +45,7 @@ func (server *Server) UpdatePayment(ctx context.Context, req *pb.UpdatePaymentRe
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return nil, status.Errorf(codes.NotFound, "payment not found")
|
||||
}
|
||||
slog.Error("update_payment (get_payment)", slog.String("invoked_by", authPayload.Email), slog.Int64("payment_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to get payment")
|
||||
}
|
||||
|
||||
@ -92,7 +94,7 @@ func (server *Server) UpdatePayment(ctx context.Context, req *pb.UpdatePaymentRe
|
||||
|
||||
payment, err := server.store.UpdatePayment(ctx, arg)
|
||||
if err != nil {
|
||||
slog.Error("Update Payment", slog.Int64("id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
slog.Error("update_payment (get_payment)", slog.String("invoked_by", authPayload.Email), slog.Int64("payment_id", int64(req.GetId())), slog.String("error", err.Error()))
|
||||
return nil, status.Error(codes.Internal, "failed to update payment")
|
||||
}
|
||||
|
||||
|
@ -32,12 +32,15 @@ func NewServer(config util.Config, store db.Store) (*Server, error) {
|
||||
}
|
||||
|
||||
logLevel := slog.LevelError
|
||||
var logSource bool
|
||||
if config.Environment == "development" {
|
||||
logLevel = slog.LevelDebug
|
||||
logSource = true
|
||||
}
|
||||
|
||||
opts := slog.HandlerOptions{
|
||||
Level: logLevel,
|
||||
Level: logLevel,
|
||||
AddSource: logSource,
|
||||
}
|
||||
logger := slog.New(slog.NewTextHandler(os.Stdout, &opts))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user