Improve client logging.
Some checks failed
Linting and tests / Linting (push) Failing after 4s
Linting and tests / Tests (push) Failing after 3s

This commit is contained in:
2025-09-10 20:04:19 +05:00
parent e3b9c9ae40
commit c2142cc1a6
15 changed files with 118 additions and 44 deletions

View File

@@ -3,7 +3,6 @@ package database
import (
"context"
"fmt"
"log/slog"
"strings"
"bunker/client/internal/services/core"
@@ -15,7 +14,7 @@ func (d *database) Exec(ctx context.Context, query string, params ...interface{}
query = d.db.Rebind(query)
}
slog.Debug("Executing query.", "query", query, "params", fmt.Sprintf("%+v", params), "module", "core/database")
d.logger.Debug("Executing query.", "query", query, "params", fmt.Sprintf("%+v", params), "module", "core/database")
if _, err := d.db.ExecContext(ctx, query, params...); err != nil {
return fmt.Errorf("%w: failed to Exec(): %w", core.ErrDatabase, err)
@@ -30,7 +29,7 @@ func (d *database) Get(ctx context.Context, target interface{}, query string, pa
query = d.db.Rebind(query)
}
slog.Debug(
d.logger.Debug(
"Getting single data from database with query.",
"query", query,
"params", fmt.Sprintf("%+v", params),
@@ -50,7 +49,7 @@ func (d *database) NamedExec(ctx context.Context, query string, param interface{
query = d.db.Rebind(query)
}
slog.Debug("Executing named query.", "query", query, "params", fmt.Sprintf("%+v", param), "module", "core/database")
d.logger.Debug("Executing named query.", "query", query, "params", fmt.Sprintf("%+v", param), "module", "core/database")
if _, err := d.db.NamedExecContext(ctx, query, param); err != nil {
return fmt.Errorf("%w: failed to NamedExec(): %w", core.ErrDatabase, err)
@@ -65,7 +64,7 @@ func (d *database) Select(ctx context.Context, target interface{}, query string,
query = d.db.Rebind(query)
}
slog.Debug(
d.logger.Debug(
"Selecting from database with query.",
"query", query,
"params", fmt.Sprintf("%+v", params),