Skip to content

Commit

Permalink
fixup: Revert log format constant changes
Browse files Browse the repository at this point in the history
  • Loading branch information
marun committed Nov 21, 2024
1 parent caa9980 commit cf8a4d4
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
3 changes: 1 addition & 2 deletions config/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/ava-labs/avalanchego/utils/compression"
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/dynamicip"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/ulimit"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/components/gas"
Expand Down Expand Up @@ -143,7 +142,7 @@ func addNodeFlags(fs *pflag.FlagSet) {
fs.String(LogsDirKey, defaultLogDir, "Logging directory for Avalanche")
fs.String(LogLevelKey, "info", "The log level. Should be one of {verbo, debug, trace, info, warn, error, fatal, off}")
fs.String(LogDisplayLevelKey, "", "The log display level. If left blank, will inherit the value of log-level. Otherwise, should be one of {verbo, debug, trace, info, warn, error, fatal, off}")
fs.String(LogFormatKey, logging.FormatModeAuto, fmt.Sprintf("The structure of log format. Defaults to '%s' which formats terminal-like logs, when the output is a terminal. Otherwise, should be one of {%s, plain, colors, json}", logging.FormatModeAuto, logging.FormatModeAuto))
fs.String(LogFormatKey, "auto", "The structure of log format. Defaults to 'auto' which formats terminal-like logs, when the output is a terminal. Otherwise, should be one of {auto, plain, colors, json}")
fs.Uint(LogRotaterMaxSizeKey, 8, "The maximum file size in megabytes of the log file before it gets rotated.")
fs.Uint(LogRotaterMaxFilesKey, 7, "The maximum number of old log files to retain. 0 means retain all old log files.")
fs.Uint(LogRotaterMaxAgeKey, 0, "The maximum number of days to retain old log files based on the timestamp encoded in their filename. 0 means retain all old log files.")
Expand Down
2 changes: 1 addition & 1 deletion tests/fixture/bootstrapmonitor/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func main() {
rootCmd.PersistentFlags().StringVar(&podName, "pod-name", os.Getenv("POD_NAME"), "The name of the pod")
rootCmd.PersistentFlags().StringVar(&nodeContainerName, "node-container-name", "", "The name of the node container in the pod")
rootCmd.PersistentFlags().StringVar(&dataDir, "data-dir", "", "The path of the data directory used for the bootstrap job")
rootCmd.PersistentFlags().StringVar(&rawLogFormat, "log-format", logging.FormatModeAuto, fmt.Sprintf("The structure of log format. Defaults to '%s' which formats terminal-like logs, when the output is a terminal. Otherwise, should be one of {%s, plain, colors, json}", logging.FormatModeAuto, logging.FormatModeAuto))
rootCmd.PersistentFlags().StringVar(&rawLogFormat, "log-format", "auto", "The structure of log format. Defaults to 'auto' which formats terminal-like logs, when the output is a terminal. Otherwise, should be one of {auto, plain, colors, json}")

versionCmd := &cobra.Command{
Use: "version",
Expand Down
3 changes: 1 addition & 2 deletions tests/fixture/tmpnet/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (

"github.com/ava-labs/avalanchego/tests"
"github.com/ava-labs/avalanchego/tests/fixture/tmpnet"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/version"
)

Expand All @@ -38,7 +37,7 @@ func main() {
Short: "tmpnetctl commands",
}
rootCmd.PersistentFlags().StringVar(&networkDir, "network-dir", os.Getenv(tmpnet.NetworkDirEnvName), "The path to the configuration directory of a temporary network")
rootCmd.PersistentFlags().StringVar(&rawLogFormat, "log-format", logging.FormatModeAuto, fmt.Sprintf("The structure of log format. Defaults to '%s' which formats terminal-like logs, when the output is a terminal. Otherwise, should be one of {%s, plain, colors, json}", logging.FormatModeAuto, logging.FormatModeAuto))
rootCmd.PersistentFlags().StringVar(&rawLogFormat, "log-format", "auto", "The structure of log format. Defaults to 'auto' which formats terminal-like logs, when the output is a terminal. Otherwise, should be one of {auto, plain, colors, json}")

versionCmd := &cobra.Command{
Use: "version",
Expand Down
2 changes: 1 addition & 1 deletion tests/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewSimpleLogger(writeCloser io.WriteCloser) logging.Logger {
}

func NewDefaultLogger(prefix string) logging.Logger {
log, err := LoggerForFormat(prefix, logging.FormatModeAuto)
log, err := LoggerForFormat(prefix, "auto")
if err != nil {
// This should never happen since auto is a valid log format
panic(err)
Expand Down
4 changes: 1 addition & 3 deletions utils/logging/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const (
Colors
JSON

FormatModeAuto = "auto"

termTimeFormat = "[01-02|15:04:05.000]"
)

Expand Down Expand Up @@ -60,7 +58,7 @@ func ToFormat(h string, fd uintptr) (Format, error) {
return Colors, nil
case "JSON":
return JSON, nil
case strings.ToUpper(FormatModeAuto):
case "AUTO":
if !term.IsTerminal(int(fd)) {
return Plain, nil
}
Expand Down

0 comments on commit cf8a4d4

Please sign in to comment.