diff options
author | 2023-02-17 12:02:29 +0100 | |
---|---|---|
committer | 2023-02-17 12:02:29 +0100 | |
commit | 68e6d08c768b789987a753d42f66caf73ce10ee1 (patch) | |
tree | 1c9eb6da6c326266d653de80684c3aec58922638 /internal/db/bundb/bundb.go | |
parent | [bugfix] Set 'discoverable' properly on API accounts (#1511) (diff) | |
download | gotosocial-68e6d08c768b789987a753d42f66caf73ce10ee1.tar.xz |
[feature] Add a request ID and include it in logs (#1476)
This adds a lightweight form of tracing to GTS. Each incoming request is
assigned a Request ID which we then pass on and log in all our log
lines. Any function that gets called downstream from an HTTP handler
should now emit a requestID=value pair whenever it logs something.
Co-authored-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/db/bundb/bundb.go')
-rw-r--r-- | internal/db/bundb/bundb.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/internal/db/bundb/bundb.go b/internal/db/bundb/bundb.go index 990eccb6b..1d0ea4822 100644 --- a/internal/db/bundb/bundb.go +++ b/internal/db/bundb/bundb.go @@ -100,11 +100,11 @@ func doMigration(ctx context.Context, db *bun.DB) error { } if group.ID == 0 { - log.Info("there are no new migrations to run") + log.Info(ctx, "there are no new migrations to run") return nil } - log.Infof("MIGRATED DATABASE TO %s", group) + log.Infof(ctx, "MIGRATED DATABASE TO %s", group) return nil } @@ -245,7 +245,7 @@ func pgConn(ctx context.Context) (*DBConn, error) { return nil, fmt.Errorf("postgres ping: %s", err) } - log.Info("connected to POSTGRES database") + log.Info(ctx, "connected to POSTGRES database") return conn, nil } @@ -268,7 +268,7 @@ func sqliteConn(ctx context.Context) (*DBConn, error) { } if address == ":memory:" { - log.Warn("using sqlite in-memory mode; all data will be deleted when gts shuts down; this mode should only be used for debugging or running tests") + log.Warn(ctx, "using sqlite in-memory mode; all data will be deleted when gts shuts down; this mode should only be used for debugging or running tests") // Use random name for in-memory instead of ':memory:', so // multiple in-mem databases can be created without conflict. @@ -319,7 +319,7 @@ func sqliteConn(ctx context.Context) (*DBConn, error) { } return nil, fmt.Errorf("sqlite ping: %s", err) } - log.Infof("connected to SQLITE database with address %s", address) + log.Infof(ctx, "connected to SQLITE database with address %s", address) return conn, nil } @@ -464,7 +464,7 @@ func sqlitePragmas(ctx context.Context, conn *DBConn) error { return fmt.Errorf("error scanning sqlite pragma %s: %w", pv, err) } - log.Infof("sqlite pragma %s set to %s", pk, res) + log.Infof(ctx, "sqlite pragma %s set to %s", pk, res) } return nil |