Skip to content

Commit

Permalink
enhance: add more log for creating new objects
Browse files Browse the repository at this point in the history
Signed-off-by: Zou Rui <21751189@zju.edu.cn>
  • Loading branch information
ZouRui89 committed Jun 3, 2018
1 parent 2979680 commit cfc1960
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apis/server/container_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func (s *Server) createContainer(ctx context.Context, rw http.ResponseWriter, re
return httputils.NewHTTPError(err, http.StatusBadRequest)
}

logCreateOptions("container", config)

name := req.FormValue("name")

// to do compensation to potential nil pointer after validation
Expand Down
2 changes: 2 additions & 0 deletions apis/server/network_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func (s *Server) createNetwork(ctx context.Context, rw http.ResponseWriter, req
return httputils.NewHTTPError(err, http.StatusBadRequest)
}

logCreateOptions("network", config)

network, err := s.NetworkMgr.Create(ctx, *config)
if err != nil {
return err
Expand Down
11 changes: 11 additions & 0 deletions apis/server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"context"
"encoding/json"
"fmt"
"io"

Expand Down Expand Up @@ -90,3 +91,13 @@ func writeLogStream(ctx context.Context, w io.Writer, tty bool, opt *types.Conta
}
}
}

// logCreateOptions will print create args in pouchd logs for debugging.
func logCreateOptions(objType string, config interface{}) {
args, err := json.Marshal(config)
if err != nil {
logrus.Errorf("failed to marsal config for %s: %v", objType, err)
} else {
logrus.Infof("create %s with args: %v", objType, string(args))
}
}
2 changes: 2 additions & 0 deletions apis/server/volume_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func (s *Server) createVolume(ctx context.Context, rw http.ResponseWriter, req *
return httputils.NewHTTPError(err, http.StatusBadRequest)
}

logCreateOptions("volume", config)

name := config.Name
driver := config.Driver
options := config.DriverOpts
Expand Down

0 comments on commit cfc1960

Please sign in to comment.