Skip to content

Commit

Permalink
Resolves #125 - Only log if directory is non empty (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-r-west authored Jun 4, 2021
1 parent 9a2abea commit 5630799
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions external/sdk/epcc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"net/url"
"os"
"path"
"path/filepath"
"strconv"
"time"

Expand Down Expand Up @@ -56,8 +55,6 @@ func NewClient(options ...ClientOptions) *Client {

logDirectory := getLogDirectory()

log.Printf("Log directory path: %s", logDirectory.Path)

exp := retry.Exponential{
Initial: 10 * time.Millisecond,
Factor: 1.5,
Expand Down Expand Up @@ -133,11 +130,7 @@ func NewClient(options ...ClientOptions) *Client {
func getLogDirectory() *url.URL {
logRootDirectory := os.Getenv("EPCC_LOG_DIR")
if len(logRootDirectory) == 0 {
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
log.Fatal(err)
}
logRootDirectory = dir
return nil
}
logDirUrl, err := url.Parse(logRootDirectory)
if err != nil {
Expand Down Expand Up @@ -178,6 +171,9 @@ func (c *Client) DoFileRequest(ctx *context.Context, path string, payload io.Rea

func (c *Client) logToDisk(requestMethod string, requestPath string, requestBytes []byte, responseBytes []byte, responseCode int) {

if(c.LogDirectory == nil) {
return
}
logDirectory, _ := url.Parse(c.LogDirectory.Path)
logDirectory.Path = path.Join(logDirectory.Path, requestPath, requestMethod, strconv.Itoa(responseCode))

Expand Down

0 comments on commit 5630799

Please sign in to comment.