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/admin.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/admin.go')
-rw-r--r-- | internal/db/bundb/admin.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/internal/db/bundb/admin.go b/internal/db/bundb/admin.go index 3c0415dca..a4bc46a73 100644 --- a/internal/db/bundb/admin.go +++ b/internal/db/bundb/admin.go @@ -93,7 +93,7 @@ func (a *adminDB) IsEmailAvailable(ctx context.Context, email string) (bool, db. func (a *adminDB) NewSignup(ctx context.Context, username string, reason string, requireApproval bool, email string, password string, signUpIP net.IP, locale string, appID string, emailVerified bool, externalID string, admin bool) (*gtsmodel.User, db.Error) { key, err := rsa.GenerateKey(rand.Reader, rsaKeyBits) if err != nil { - log.Errorf("error creating new rsa key: %s", err) + log.Errorf(ctx, "error creating new rsa key: %s", err) return nil, err } @@ -107,7 +107,7 @@ func (a *adminDB) NewSignup(ctx context.Context, username string, reason string, Scan(ctx); err != nil { err = a.conn.ProcessError(err) if err != db.ErrNoEntries { - log.Errorf("error checking for existing account: %s", err) + log.Errorf(ctx, "error checking for existing account: %s", err) return nil, err } @@ -207,13 +207,13 @@ func (a *adminDB) CreateInstanceAccount(ctx context.Context) db.Error { return err } if exists { - log.Infof("instance account %s already exists", username) + log.Infof(ctx, "instance account %s already exists", username) return nil } key, err := rsa.GenerateKey(rand.Reader, rsaKeyBits) if err != nil { - log.Errorf("error creating new rsa key: %s", err) + log.Errorf(ctx, "error creating new rsa key: %s", err) return err } @@ -245,7 +245,7 @@ func (a *adminDB) CreateInstanceAccount(ctx context.Context) db.Error { return err } - log.Infof("instance account %s CREATED with id %s", username, acct.ID) + log.Infof(ctx, "instance account %s CREATED with id %s", username, acct.ID) return nil } @@ -265,7 +265,7 @@ func (a *adminDB) CreateInstanceInstance(ctx context.Context) db.Error { return err } if exists { - log.Infof("instance entry already exists") + log.Infof(ctx, "instance entry already exists") return nil } @@ -290,6 +290,6 @@ func (a *adminDB) CreateInstanceInstance(ctx context.Context) db.Error { return a.conn.ProcessError(err) } - log.Infof("created instance instance %s with id %s", host, i.ID) + log.Infof(ctx, "created instance instance %s with id %s", host, i.ID) return nil } |