diff --git a/provisioning.go b/provisioning.go index 3218702c..5658bf44 100644 --- a/provisioning.go +++ b/provisioning.go @@ -171,16 +171,13 @@ func (prov *ProvisioningAPI) resolveIdentifier(user *User, phoneNum string) (int phoneNum = "+" + phoneNum } if user.SignalDevice == nil { - prov.log.Debug().Msgf("ResolveIdentifier from %v, no device found", user.MXID) return http.StatusUnauthorized, nil, fmt.Errorf("Not currently connected to Signal") } contact, err := user.SignalDevice.ContactByE164(phoneNum) if err != nil { - prov.log.Err(err).Msgf("ResolveIdentifier from %v, error looking up contact", user.MXID) return http.StatusInternalServerError, nil, fmt.Errorf("Error looking up number in local contact list: %w", err) } if contact == nil { - prov.log.Debug().Msgf("ResolveIdentifier from %v, contact not found", user.MXID) return http.StatusNotFound, nil, fmt.Errorf("The bridge does not have the Signal ID for the number %s", phoneNum) } @@ -204,16 +201,22 @@ func (prov *ProvisioningAPI) resolveIdentifier(user *User, phoneNum string) (int func (prov *ProvisioningAPI) ResolveIdentifier(w http.ResponseWriter, r *http.Request) { user := r.Context().Value("user").(*User) phoneNum, _ := mux.Vars(r)["phonenum"] - prov.log.Debug().Msgf("ResolveIdentifier from %v, phone number: %v", user.MXID, phoneNum) + + log := prov.log.With(). + Str("action", "resolve_identifier"). + Str("user_id", user.MXID.String()). + Str("phone_num", phoneNum). + Logger() + log.Debug().Msg("resolving identifier") status, resp, err := prov.resolveIdentifier(user, phoneNum) if err != nil { errCode := "M_INTERNAL" if status == http.StatusNotFound { - prov.log.Debug().Msgf("ResolveIdentifier from %v, contact not found", user.MXID) + log.Debug().Msg("contact not found") errCode = "M_NOT_FOUND" } else { - prov.log.Err(err).Msgf("ResolveIdentifier from %v, error looking up contact", user.MXID) + log.Err(err).Msg("error looking up contact") } jsonResponse(w, status, Error{ Success: false,