refactor logger calls

This commit is contained in:
Roman Isaev 2025-01-05 02:24:40 +00:00
parent 7ffb2c1d81
commit c06e0aa206
No known key found for this signature in database
GPG key ID: 7BE2B6A6C89AEC7F
4 changed files with 6 additions and 6 deletions

View file

@ -724,7 +724,7 @@ func AdminUserDevicesDelete(
defer req.Body.Close() defer req.Body.Close()
if err = json.NewDecoder(req.Body).Decode(&payload); err != nil { if err = json.NewDecoder(req.Body).Decode(&payload); err != nil {
util.GetLogger(req.Context()).WithError(err).Error("unable to decode device deletion request") logger.WithError(err).Error("unable to decode device deletion request")
return util.JSONResponse{ return util.JSONResponse{
Code: http.StatusInternalServerError, Code: http.StatusInternalServerError,
JSON: spec.InternalServerError{}, JSON: spec.InternalServerError{},
@ -860,7 +860,7 @@ func AdminCreateOrModifyAccount(req *http.Request, userAPI userapi.ClientUserAPI
DisplayName: r.DisplayName, DisplayName: r.DisplayName,
}, &res) }, &res)
if err != nil { if err != nil {
util.GetLogger(req.Context()).WithError(err).Debugln("Failed creating account") logger.WithError(err).Debugln("Failed creating account")
return util.MessageResponse(http.StatusBadRequest, err.Error()) return util.MessageResponse(http.StatusBadRequest, err.Error())
} }
if res.AccountCreated { if res.AccountCreated {

View file

@ -173,7 +173,6 @@ func (m *MSC3861UserVerifier) getUserByAccessToken(ctx context.Context, token st
logger.WithError(err).Error("MSC3861UserVerifier:introspectToken") logger.WithError(err).Error("MSC3861UserVerifier:introspectToken")
return nil, err return nil, err
} }
logger.Debugf("Introspection result: %+v", *introspectionResult)
if !introspectionResult.Active { if !introspectionResult.Active {
return nil, &mscError{Code: codeInvalidClientToken, Msg: "Token is not active"} return nil, &mscError{Code: codeInvalidClientToken, Msg: "Token is not active"}

View file

@ -471,10 +471,11 @@ func (a *UserInternalAPI) processOtherSignatures(
func (a *UserInternalAPI) crossSigningKeysFromDatabase( func (a *UserInternalAPI) crossSigningKeysFromDatabase(
ctx context.Context, req *api.QueryKeysRequest, res *api.QueryKeysResponse, ctx context.Context, req *api.QueryKeysRequest, res *api.QueryKeysResponse,
) { ) {
logger := logrus.WithContext(ctx)
for targetUserID := range req.UserToDevices { for targetUserID := range req.UserToDevices {
keys, err := a.KeyDatabase.CrossSigningKeysForUser(ctx, targetUserID) keys, err := a.KeyDatabase.CrossSigningKeysForUser(ctx, targetUserID)
if err != nil { if err != nil {
logrus.WithError(err).Errorf("Failed to get cross-signing keys for user %q", targetUserID) logger.WithError(err).Errorf("Failed to get cross-signing keys for user %q", targetUserID)
continue continue
} }
@ -487,7 +488,7 @@ func (a *UserInternalAPI) crossSigningKeysFromDatabase(
sigMap, err := a.KeyDatabase.CrossSigningSigsForTarget(ctx, req.UserID, targetUserID, keyID) sigMap, err := a.KeyDatabase.CrossSigningSigsForTarget(ctx, req.UserID, targetUserID, keyID)
if err != nil && err != sql.ErrNoRows { if err != nil && err != sql.ErrNoRows {
logrus.WithError(err).Errorf("Failed to get cross-signing signatures for user %q key %q", targetUserID, keyID) logger.WithError(err).Errorf("Failed to get cross-signing signatures for user %q key %q", targetUserID, keyID)
continue continue
} }

View file

@ -285,7 +285,7 @@ func (a *UserInternalAPI) QueryKeys(ctx context.Context, req *api.QueryKeysReque
DeviceIDs: dids, DeviceIDs: dids,
}, &queryRes) }, &queryRes)
if err != nil { if err != nil {
util.GetLogger(ctx).Warnf("Failed to QueryDeviceInfos for device IDs, display names will be missing") util.GetLogger(ctx).WithError(err).Warnf("Failed to QueryDeviceInfos for device IDs, display names will be missing")
} }
if res.DeviceKeys[userID] == nil { if res.DeviceKeys[userID] == nil {