Skip to content

Commit

Permalink
Disable output to log file by default (istio#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
ostromart authored and istio-testing committed Oct 18, 2019
1 parent cd891af commit e43da2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ cluster.env
kubedns
# codegen stuff
*.orig
.mesh-cli.log
#mandiff output
out/
build/out/
Expand Down
12 changes: 8 additions & 4 deletions cmd/mesh/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ import (
)

const (
// logToFile controls whether to log to logFilePath
logToFile = false
logFilePath = "./.mesh-cli.log"
)

func initLogsOrExit(args *rootArgs) {
// Only the logs for the last command are of interest.
// Remove any previous log to avoid indefinite accumulation.
_ = os.Remove(logFilePath)
if logToFile {
// Only the logs for the last command are of interest.
// Remove any previous log to avoid indefinite accumulation.
_ = os.Remove(logFilePath)
}
if err := configLogs(args.logToStdErr); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Could not configure logs: %s", err)
os.Exit(1)
Expand All @@ -40,7 +44,7 @@ func initLogsOrExit(args *rootArgs) {

func configLogs(logToStdErr bool) error {
opt := log.DefaultOptions()
if !logToStdErr {
if !logToStdErr && logToFile {
opt.ErrorOutputPaths = []string{logFilePath}
opt.OutputPaths = []string{logFilePath}
}
Expand Down

0 comments on commit e43da2c

Please sign in to comment.