add ids to graph access logs

Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
jkoberg
2023-06-22 11:04:00 +02:00
parent d35a4ac4a6
commit 3fe5e2b011
4 changed files with 26 additions and 21 deletions

View File

@@ -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

View File

@@ -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,9 @@ 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")
logger.Info().Str("classID", classID).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")
@@ -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,9 @@ 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")
logger.Info().Str("classID", classID).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")

View File

@@ -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,9 @@ 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")
logger.Info().Str("schoolID", schoolID).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")
@@ -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,9 @@ 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")
logger.Info().Str("schoolID", schoolID).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")

View File

@@ -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")