Skip to content

Commit

Permalink
feat: add CUSTOM type to support custom log path set by log-path flag…
Browse files Browse the repository at this point in the history
…, conveniently saving the log file in custom path, for the logs persistence scene.

Signed-off-by: NigelWu95 <[email protected]>
  • Loading branch information
NigelWu95 authored and xcaspar committed Dec 16, 2021
1 parent 537506b commit 891eddc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions util/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,25 @@ import (
const (
Blade = 1
Bin = 2
Custom= 3
)

const BladeLog = "chaosblade.log"

var (
Debug bool
LogPath string
LogLevel string
)

func AddDebugFlag() {
flag.BoolVar(&Debug, "debug", false, "set debug mode")
}

func AddLogPathFlag() {
flag.StringVar(&LogPath, "log-path", GetProgramPath(), "the directory path to save chaosblade.log.")
}

func AddLogLevelFlag() {
flag.StringVar(&LogLevel, "log-level", "info", "level of logging wanted.")
}
Expand Down Expand Up @@ -127,6 +133,8 @@ func GetLogPath(programType int) (string, error) {
binDir = GetProgramPath()
case Bin:
binDir = GetProgramParentPath()
case Custom:
binDir = LogPath
default:
binDir = GetProgramPath()
}
Expand Down

0 comments on commit 891eddc

Please sign in to comment.