summaryrefslogtreecommitdiff
path: root/internal/command/shared/customaction
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2021-10-13 23:23:42 +0000
committerAsh McKenzie <amckenzie@gitlab.com>2021-10-13 23:23:42 +0000
commit9dcfcd3a1d3001fb87b6e807f7fed31a05f509b2 (patch)
tree45ba635e5efef209eea46873158d401808a4fea8 /internal/command/shared/customaction
parent7cb9be1e9bc1795d92f4f724e2182af019e3d0a8 (diff)
parent34fa7eb3499c0f85c8610f89c120c1b3c56c1462 (diff)
downloadgitlab-shell-9dcfcd3a1d3001fb87b6e807f7fed31a05f509b2.tar.gz
Merge branch '499-log-non-git-commands' into 'main'
Improve logging for non-git commands See merge request gitlab-org/gitlab-shell!538
Diffstat (limited to 'internal/command/shared/customaction')
-rw-r--r--internal/command/shared/customaction/customaction.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/internal/command/shared/customaction/customaction.go b/internal/command/shared/customaction/customaction.go
index 73d2ce4..191ec42 100644
--- a/internal/command/shared/customaction/customaction.go
+++ b/internal/command/shared/customaction/customaction.go
@@ -4,19 +4,17 @@ import (
"bytes"
"context"
"errors"
-
- "gitlab.com/gitlab-org/gitlab-shell/client"
-
"io"
"net/http"
+ "gitlab.com/gitlab-org/labkit/log"
+
+ "gitlab.com/gitlab-org/gitlab-shell/client"
"gitlab.com/gitlab-org/gitlab-shell/internal/command/readwriter"
"gitlab.com/gitlab-org/gitlab-shell/internal/config"
"gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet"
"gitlab.com/gitlab-org/gitlab-shell/internal/gitlabnet/accessverifier"
"gitlab.com/gitlab-org/gitlab-shell/internal/pktline"
-
- "gitlab.com/gitlab-org/labkit/log"
)
type Request struct {
@@ -59,12 +57,12 @@ func (c *Command) processApiEndpoints(ctx context.Context, response *accessverif
request.Data.UserId = response.Who
for _, endpoint := range data.ApiEndpoints {
- fields := log.Fields{
+ ctxlog := log.WithContextFields(ctx, log.Fields{
"primary_repo": data.PrimaryRepo,
"endpoint": endpoint,
- }
+ })
- log.WithContextFields(ctx, fields).Info("Performing custom action")
+ ctxlog.Info("customaction: processApiEndpoints: Performing custom action")
response, err := c.performRequest(ctx, client, endpoint, request)
if err != nil {
@@ -90,6 +88,10 @@ func (c *Command) processApiEndpoints(ctx context.Context, response *accessverif
} else {
output = c.readFromStdinNoEOF()
}
+ ctxlog.WithFields(log.Fields{
+ "eof_sent": c.EOFSent,
+ "stdin_bytes": len(output),
+ }).Debug("customaction: processApiEndpoints: stdin buffered")
request.Output = output
}