Skip to content

Commit

Permalink
feat: add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh4723 committed Aug 19, 2024
1 parent 2040667 commit 82a4f33
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/bucket-listobjects-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"net/http"
"strconv"
"strings"
"time"

"github.com/gorilla/mux"
"github.com/minio/minio/internal/logger"
Expand Down Expand Up @@ -250,6 +251,11 @@ func (api objectAPIHandlers) ListObjectsV2MHandler(w http.ResponseWriter, r *htt
// MinIO continues to support ListObjectsV1 for supporting legacy tools.
func (api objectAPIHandlers) ListObjectsV2Handler(w http.ResponseWriter, r *http.Request) {
fmt.Println("ListObjectsV2Handler")
st := time.Now()
defer func() {
elapsed := time.Since(st).Milliseconds()
fmt.Printf("ListObjectsV2Handler took %d ms\n", elapsed)
}()
ctx := newContext(r, w, "ListObjectsV2")

defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
Expand Down Expand Up @@ -371,6 +377,11 @@ func proxyRequestByNodeIndex(ctx context.Context, w http.ResponseWriter, r *http
// criteria to return a subset of the objects in a bucket.
func (api objectAPIHandlers) ListObjectsV1Handler(w http.ResponseWriter, r *http.Request) {
fmt.Println("ListObjectsV1Handler")
st := time.Now()
defer func() {
elapsed := time.Since(st).Milliseconds()
fmt.Printf("ListObjectsV1Handler took %d ms\n", elapsed)
}()
ctx := newContext(r, w, "ListObjectsV1")

defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
Expand Down
19 changes: 19 additions & 0 deletions cmd/object-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj
}) {
getObjectInfo := objectAPI.GetObjectInfo
if api.CacheAPI() != nil {
fmt.Println("Get ObjectInfo from cache")
getObjectInfo = api.CacheAPI().GetObjectInfo
}

Expand All @@ -369,6 +370,7 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj

getObjectNInfo := objectAPI.GetObjectNInfo
if api.CacheAPI() != nil {
fmt.Println("Get ObjectNNNInfo from cache")
getObjectNInfo = api.CacheAPI().GetObjectNInfo
}

Expand Down Expand Up @@ -552,6 +554,12 @@ func (api objectAPIHandlers) getObjectHandler(ctx context.Context, objectAPI Obj
// This implementation of the GET operation retrieves object. To use GET,
// you must have READ access to the object.
func (api objectAPIHandlers) GetObjectHandler(w http.ResponseWriter, r *http.Request) {
fmt.Println("GetObjectHandler")
st := time.Now()
defer func() {
elapsed := time.Since(st).Milliseconds()
fmt.Printf("GetObjectHandler took %d ms\n", elapsed)
}()
ctx := newContext(r, w, "GetObject")

defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
Expand Down Expand Up @@ -1523,6 +1531,12 @@ func (api objectAPIHandlers) CopyObjectHandler(w http.ResponseWriter, r *http.Re
// - X-Amz-Server-Side-Encryption-Customer-Key
// - X-Amz-Copy-Source-Server-Side-Encryption-Customer-Key
func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Request) {
fmt.Println("PutObjectHandler....")
st := time.Now()
defer func() {
elapsed := time.Since(st).Milliseconds()
fmt.Printf("PutObjectHandler took %d ms\n", elapsed)
}()
ctx := newContext(r, w, "PutObject")
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))

Expand Down Expand Up @@ -1720,6 +1734,7 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
}

if api.CacheAPI() != nil {
fmt.Println("Put Object cache")
putObject = api.CacheAPI().PutObject
}

Expand Down Expand Up @@ -1868,6 +1883,7 @@ func (api objectAPIHandlers) PutObjectHandler(w http.ResponseWriter, r *http.Req
// This implementation of the PUT operation adds multiple objects to a bucket.

func (api objectAPIHandlers) PutMultipleObjectsHandler(w http.ResponseWriter, r *http.Request) {
fmt.Println("Harsh PutMultipleObjects")
ctx := newContext(r, w, "PutMultipleObjects")
defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))

Expand Down Expand Up @@ -2122,6 +2138,7 @@ func (api objectAPIHandlers) PutObjectExtractHandler(w http.ResponseWriter, r *h
holdPerms := isPutActionAllowed(ctx, getRequestAuthType(r), bucket, object, r, iampolicy.PutObjectLegalHoldAction)

if api.CacheAPI() != nil {
fmt.Println("Put Object cache 22")
putObject = api.CacheAPI().PutObject
}

Expand Down Expand Up @@ -3440,6 +3457,7 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite

// DeleteObjectHandler - delete an object
func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.Request) {
fmt.Println("DeleteObjectHandler")
ctx := newContext(r, w, "DeleteObject")

defer logger.AuditLog(ctx, w, r, mustGetClaimsFromToken(r))
Expand Down Expand Up @@ -3554,6 +3572,7 @@ func (api objectAPIHandlers) DeleteObjectHandler(w http.ResponseWriter, r *http.
// http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectDELETE.html
objInfo, err := deleteObject(ctx, bucket, object, opts)
if err != nil {
fmt.Println("DeleteObjectHandler err", err)
switch err.(type) {
case BucketNotFound:
// When bucket doesn't exist specially handle it.
Expand Down

0 comments on commit 82a4f33

Please sign in to comment.