Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
Set default logfile path for dfdaemon/dfget
Browse files Browse the repository at this point in the history
Signed-off-by: YanzheL <[email protected]>
  • Loading branch information
YanzheL committed Jan 14, 2020
1 parent ebfc638 commit c02b0b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion cmd/dfdaemon/app/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ func initLogger(cfg config.Properties) error {
}
cfg.WorkHome = filepath.Join(current.HomeDir, ".small-dragonfly")
}

if cfg.LogConfig.Path == "" {
cfg.LogConfig.Path = filepath.Join(cfg.WorkHome, "logs", "dfdaemon.log")
}
opts := []dflog.Option{
dflog.WithLogFile(cfg.LogConfig.Path, cfg.LogConfig.MaxSize, cfg.LogConfig.MaxBackups),
dflog.WithSign(fmt.Sprintf("%d", os.Getpid())),
Expand Down
6 changes: 4 additions & 2 deletions cmd/dfget/app/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@ func initProperties() ([]*propertiesResult, error) {
// while console log will output the dfget client's log in console/terminal for
// debugging usage.
func initClientLog() error {
logFilePath := filepath.Join(cfg.WorkHome, "logs", "dfclient.log")
if cfg.LogConfig.Path == "" {
cfg.LogConfig.Path = filepath.Join(cfg.WorkHome, "logs", "dfclient.log")
}

opts := []dflog.Option{
dflog.WithLogFile(logFilePath, cfg.LogConfig.MaxSize, cfg.LogConfig.MaxBackups),
dflog.WithLogFile(cfg.LogConfig.Path, cfg.LogConfig.MaxSize, cfg.LogConfig.MaxBackups),
dflog.WithSign(cfg.Sign),
dflog.WithDebug(cfg.Verbose),
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/dfget/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ func runServer() error {
}

func initServerLog() error {
logFilePath := filepath.Join(cfg.WorkHome, "logs", "dfserver.log")

if cfg.LogConfig.Path == "" {
cfg.LogConfig.Path = filepath.Join(cfg.WorkHome, "logs", "dfserver.log")
}
opts := []dflog.Option{
dflog.WithLogFile(logFilePath, cfg.LogConfig.MaxSize, cfg.LogConfig.MaxBackups),
dflog.WithLogFile(cfg.LogConfig.Path, cfg.LogConfig.MaxSize, cfg.LogConfig.MaxBackups),
dflog.WithSign(cfg.Sign),
dflog.WithDebug(cfg.Verbose),
}
Expand Down

0 comments on commit c02b0b0

Please sign in to comment.