diff --git a/changelog/unreleased/add-ids-to-graph-education-logging.md b/changelog/unreleased/add-ids-to-graph-education-logging.md new file mode 100644 index 000000000..d628aa845 --- /dev/null +++ b/changelog/unreleased/add-ids-to-graph-education-logging.md @@ -0,0 +1,5 @@ +Enhancement: Add IDs to graph resource logging + +Graph access logs were unsuable as they didn't contain IDs to match them to a request + +https://github.com/owncloud/ocis/pull/6593 diff --git a/services/graph/pkg/service/v0/educationclasses.go b/services/graph/pkg/service/v0/educationclasses.go index 646099dc1..61fb8c2e1 100644 --- a/services/graph/pkg/service/v0/educationclasses.go +++ b/services/graph/pkg/service/v0/educationclasses.go @@ -93,8 +93,8 @@ func (g Graph) PostEducationClass(w http.ResponseWriter, r *http.Request) { // PatchEducationClass implements the Service interface. func (g Graph) PatchEducationClass(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling patch education class") classID := chi.URLParam(r, "classID") + logger.Info().Str("classID", classID).Msg("calling patch education class") classID, err := url.PathUnescape(classID) if err != nil { logger.Debug().Str("id", classID).Msg("could not change class: unescaping class id failed") @@ -196,8 +196,8 @@ func (g Graph) PatchEducationClass(w http.ResponseWriter, r *http.Request) { // GetEducationClass implements the Service interface. func (g Graph) GetEducationClass(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling get education class") classID := chi.URLParam(r, "classID") + logger.Info().Str("classID", classID).Msg("calling get education class") classID, err := url.PathUnescape(classID) if err != nil { logger.Debug().Str("id", classID).Msg("could not get class: unescaping class id failed") @@ -228,8 +228,8 @@ func (g Graph) GetEducationClass(w http.ResponseWriter, r *http.Request) { // DeleteEducationClass implements the Service interface. func (g Graph) DeleteEducationClass(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling delete class") classID := chi.URLParam(r, "classID") + logger.Info().Str("classID", classID).Msg("calling delete class") classID, err := url.PathUnescape(classID) if err != nil { logger.Debug().Err(err).Str("id", classID).Msg("could not delete class: unescaping class id failed") @@ -264,8 +264,8 @@ func (g Graph) DeleteEducationClass(w http.ResponseWriter, r *http.Request) { // GetEducationClassMembers implements the Service interface. func (g Graph) GetEducationClassMembers(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling get class members") classID := chi.URLParam(r, "classID") + logger.Info().Str("classID", classID).Msg("calling get class members") classID, err := url.PathUnescape(classID) if err != nil { logger.Debug().Str("id", classID).Msg("could not get class members: unescaping class id failed") @@ -294,9 +294,9 @@ func (g Graph) GetEducationClassMembers(w http.ResponseWriter, r *http.Request) // PostEducationClassMember implements the Service interface. func (g Graph) PostEducationClassMember(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("Calling post class member") classID := chi.URLParam(r, "classID") + logger.Info().Str("classID", classID).Msg("Calling post class member") classID, err := url.PathUnescape(classID) if err != nil { logger.Debug(). @@ -362,9 +362,10 @@ func (g Graph) PostEducationClassMember(w http.ResponseWriter, r *http.Request) // DeleteEducationClassMember implements the Service interface. func (g Graph) DeleteEducationClassMember(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling delete class member") classID := chi.URLParam(r, "classID") + memberID := chi.URLParam(r, "memberID") + logger.Info().Str("classID", classID).Str("memberID", memberID).Msg("calling delete class member") classID, err := url.PathUnescape(classID) if err != nil { logger.Debug().Err(err).Str("id", classID).Msg("could not delete class member: unescaping class id failed") @@ -378,7 +379,6 @@ func (g Graph) DeleteEducationClassMember(w http.ResponseWriter, r *http.Request return } - memberID := chi.URLParam(r, "memberID") memberID, err = url.PathUnescape(memberID) if err != nil { logger.Debug().Err(err).Str("id", memberID).Msg("could not delete class member: unescaping member id failed") @@ -410,8 +410,8 @@ func (g Graph) DeleteEducationClassMember(w http.ResponseWriter, r *http.Request // GetEducationClassTeachers implements the Service interface. func (g Graph) GetEducationClassTeachers(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling get class teachers") classID := chi.URLParam(r, "classID") + logger.Info().Str("classID", classID).Msg("calling get class teachers") classID, err := url.PathUnescape(classID) if err != nil { logger.Debug().Str("id", classID).Msg("could not get class teachers: unescaping class id failed") @@ -440,9 +440,9 @@ func (g Graph) GetEducationClassTeachers(w http.ResponseWriter, r *http.Request) // PostEducationClassTeacher implements the Service interface. func (g Graph) PostEducationClassTeacher(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("Calling post class teacher") classID := chi.URLParam(r, "classID") + logger.Info().Str("classID", classID).Msg("Calling post class teacher") classID, err := url.PathUnescape(classID) if err != nil { logger.Debug(). @@ -508,9 +508,10 @@ func (g Graph) PostEducationClassTeacher(w http.ResponseWriter, r *http.Request) // DeleteEducationClassTeacher implements the Service interface. func (g Graph) DeleteEducationClassTeacher(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling delete class teacher") classID := chi.URLParam(r, "classID") + teacherID := chi.URLParam(r, "teacherID") + logger.Info().Str("classID", classID).Str("teacherID", teacherID).Msg("calling delete class teacher") classID, err := url.PathUnescape(classID) if err != nil { logger.Debug().Err(err).Str("id", classID).Msg("could not delete class teacher: unescaping class id failed") @@ -524,7 +525,6 @@ func (g Graph) DeleteEducationClassTeacher(w http.ResponseWriter, r *http.Reques return } - teacherID := chi.URLParam(r, "teacherID") teacherID, err = url.PathUnescape(teacherID) if err != nil { logger.Debug().Err(err).Str("id", teacherID).Msg("could not delete class teacher: unescaping teacher id failed") diff --git a/services/graph/pkg/service/v0/educationschools.go b/services/graph/pkg/service/v0/educationschools.go index f8aec173a..e061a5c87 100644 --- a/services/graph/pkg/service/v0/educationschools.go +++ b/services/graph/pkg/service/v0/educationschools.go @@ -102,8 +102,8 @@ func (g Graph) PostEducationSchool(w http.ResponseWriter, r *http.Request) { // PatchEducationSchool implements the Service interface. func (g Graph) PatchEducationSchool(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling patch school") schoolID := chi.URLParam(r, "schoolID") + logger.Info().Str("schoolID", schoolID).Msg("calling patch school") schoolID, err := url.PathUnescape(schoolID) if err != nil { logger.Debug().Str("id", schoolID).Msg("could not update school: unescaping school id failed") @@ -146,8 +146,8 @@ func (g Graph) PatchEducationSchool(w http.ResponseWriter, r *http.Request) { // GetEducationSchool implements the Service interface. func (g Graph) GetEducationSchool(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling get school") schoolID := chi.URLParam(r, "schoolID") + logger.Info().Str("schoolID", schoolID).Msg("calling get school") schoolID, err := url.PathUnescape(schoolID) if err != nil { logger.Debug().Str("id", schoolID).Msg("could not get school: unescaping school id failed") @@ -178,8 +178,8 @@ func (g Graph) GetEducationSchool(w http.ResponseWriter, r *http.Request) { // DeleteEducationSchool implements the Service interface. func (g Graph) DeleteEducationSchool(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling delete school") schoolID := chi.URLParam(r, "schoolID") + logger.Info().Str("schoolID", schoolID).Msg("calling delete school") schoolID, err := url.PathUnescape(schoolID) if err != nil { logger.Debug().Err(err).Str("id", schoolID).Msg("could not delete school: unescaping school id failed") @@ -238,8 +238,8 @@ func (g Graph) DeleteEducationSchool(w http.ResponseWriter, r *http.Request) { // GetEducationSchoolUsers implements the Service interface. func (g Graph) GetEducationSchoolUsers(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling get school users") schoolID := chi.URLParam(r, "schoolID") + logger.Info().Str("schoolID", schoolID).Msg("calling get school users") schoolID, err := url.PathUnescape(schoolID) if err != nil { logger.Debug().Str("id", schoolID).Msg("could not get school users: unescaping school id failed") @@ -268,9 +268,9 @@ func (g Graph) GetEducationSchoolUsers(w http.ResponseWriter, r *http.Request) { // PostEducationSchoolUser implements the Service interface. func (g Graph) PostEducationSchoolUser(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("Calling post school user") schoolID := chi.URLParam(r, "schoolID") + logger.Info().Str("schoolID", schoolID).Msg("Calling post school user") schoolID, err := url.PathUnescape(schoolID) if err != nil { logger.Debug(). @@ -340,9 +340,10 @@ func (g Graph) PostEducationSchoolUser(w http.ResponseWriter, r *http.Request) { // DeleteEducationSchoolUser implements the Service interface. func (g Graph) DeleteEducationSchoolUser(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling delete school member") schoolID := chi.URLParam(r, "schoolID") + userID := chi.URLParam(r, "userID") + logger.Info().Str("schoolID", schoolID).Str("userID", userID).Msg("calling delete school member") schoolID, err := url.PathUnescape(schoolID) if err != nil { logger.Debug().Err(err).Str("id", schoolID).Msg("could not delete school member: unescaping school id failed") @@ -356,7 +357,6 @@ func (g Graph) DeleteEducationSchoolUser(w http.ResponseWriter, r *http.Request) return } - userID := chi.URLParam(r, "userID") userID, err = url.PathUnescape(userID) if err != nil { logger.Debug().Err(err).Str("id", userID).Msg("could not delete school member: unescaping member id failed") @@ -393,8 +393,8 @@ func (g Graph) DeleteEducationSchoolUser(w http.ResponseWriter, r *http.Request) // GetEducationSchoolClasses implements the Service interface. func (g Graph) GetEducationSchoolClasses(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling get school classes") schoolID := chi.URLParam(r, "schoolID") + logger.Info().Str("schoolID", schoolID).Msg("calling get school classes") schoolID, err := url.PathUnescape(schoolID) if err != nil { logger.Debug().Str("id", schoolID).Msg("could not get school users: unescaping school id failed") @@ -423,9 +423,9 @@ func (g Graph) GetEducationSchoolClasses(w http.ResponseWriter, r *http.Request) // PostEducationSchoolClass implements the Service interface. func (g Graph) PostEducationSchoolClass(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("Calling post school class") schoolID := chi.URLParam(r, "schoolID") + logger.Info().Str("schoolID", schoolID).Msg("Calling post school class") schoolID, err := url.PathUnescape(schoolID) if err != nil { logger.Debug(). @@ -495,9 +495,10 @@ func (g Graph) PostEducationSchoolClass(w http.ResponseWriter, r *http.Request) // DeleteEducationSchoolClass implements the Service interface. func (g Graph) DeleteEducationSchoolClass(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling delete school class") schoolID := chi.URLParam(r, "schoolID") + classID := chi.URLParam(r, "classID") + logger.Info().Str("schoolID", schoolID).Str("classID", classID).Msg("calling delete school class") schoolID, err := url.PathUnescape(schoolID) if err != nil { logger.Debug().Err(err).Str("id", schoolID).Msg("could not delete school class: unescaping school id failed") @@ -511,7 +512,6 @@ func (g Graph) DeleteEducationSchoolClass(w http.ResponseWriter, r *http.Request return } - classID := chi.URLParam(r, "classID") classID, err = url.PathUnescape(classID) if err != nil { logger.Debug().Err(err).Str("id", classID).Msg("could not delete school class: unescaping class id failed") diff --git a/services/graph/pkg/service/v0/educationuser.go b/services/graph/pkg/service/v0/educationuser.go index 3ab8572a2..e7e003c12 100644 --- a/services/graph/pkg/service/v0/educationuser.go +++ b/services/graph/pkg/service/v0/educationuser.go @@ -155,8 +155,8 @@ func (g Graph) PostEducationUser(w http.ResponseWriter, r *http.Request) { // GetEducationUser implements the Service interface. func (g Graph) GetEducationUser(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling get education user") userID := chi.URLParam(r, "userID") + logger.Info().Str("userID", userID).Msg("calling get education user") userID, err := url.PathUnescape(userID) if err != nil { logger.Debug().Err(err).Str("id", userID).Msg("could not get education user: unescaping education user id failed") @@ -186,8 +186,8 @@ func (g Graph) GetEducationUser(w http.ResponseWriter, r *http.Request) { // DeleteEducationUser implements the Service interface. func (g Graph) DeleteEducationUser(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling delete education user") userID := chi.URLParam(r, "userID") + logger.Info().Str("userID", userID).Msg("calling delete education user") userID, err := url.PathUnescape(userID) if err != nil { logger.Debug().Err(err).Str("id", userID).Msg("could not delete education user: unescaping education user id failed") @@ -298,8 +298,8 @@ func (g Graph) DeleteEducationUser(w http.ResponseWriter, r *http.Request) { // ExistingUser func (g Graph) PatchEducationUser(w http.ResponseWriter, r *http.Request) { logger := g.logger.SubloggerWithRequestID(r.Context()) - logger.Info().Msg("calling patch education user") nameOrID := chi.URLParam(r, "userID") + logger.Info().Str("userID", nameOrID).Msg("calling patch education user") nameOrID, err := url.PathUnescape(nameOrID) if err != nil { logger.Debug().Err(err).Str("id", nameOrID).Msg("could not update education user: unescaping education user id failed")