Skip to content

Commit

Permalink
object/gluster: allow customizing log path (#4026)
Browse files Browse the repository at this point in the history
Try using `JFS_GLUSTER_LOG_PATH=/dev/stdout` or
`JFS_GLUSTER_LOG_PATH=/dev/stderr` to redirect the log within k8s.
  • Loading branch information
SandyXSD authored Aug 31, 2023
1 parent 94e7a1b commit 3a1c28c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/object/gluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ func newGluster(endpoint, ak, sk, token string) (ObjectStorage, error) {
level = gfapi.LogTrace
}
}
logPath := os.Getenv("JFS_GLUSTER_LOG_PATH")
hosts := strings.Split(uri.Host, ",")
pid := os.Getpid()
ostore := gluster{
Expand All @@ -310,7 +311,11 @@ func newGluster(endpoint, ak, sk, token string) (ObjectStorage, error) {
if err != nil {
return nil, fmt.Errorf("init %s: %s", name, err)
}
err = v.SetLogging(fmt.Sprintf("/var/log/glusterfs/%s-%s-%d-%d.log", hosts[0], name, pid, i), level)
if logPath == "" {
err = v.SetLogging(fmt.Sprintf("/var/log/glusterfs/%s-%s-%d-%d.log", hosts[0], name, pid, i), level)
} else {
err = v.SetLogging(logPath, level)
}
if err != nil {
logger.Warnf("Set gluster logging for vol %s: %s", name, err)
}
Expand Down

0 comments on commit 3a1c28c

Please sign in to comment.