Suppress the InfluxDB banner if the log output is not a TTY
parent
b866943945
commit
1303030184
|
@ -94,7 +94,7 @@ func (cmd *Command) Run(args ...string) error {
|
|||
}
|
||||
|
||||
// Print sweet InfluxDB logo.
|
||||
if !suppressLogo {
|
||||
if !suppressLogo && logger.IsTerminal(cmd.Stdout) {
|
||||
fmt.Fprint(cmd.Stdout, logo)
|
||||
}
|
||||
|
||||
|
|
|
@ -286,6 +286,7 @@
|
|||
# level = "info"
|
||||
|
||||
# Suppresses the logo output that is printed when the program is started.
|
||||
# The logo is always suppressed if STDOUT is not a TTY.
|
||||
# suppress-logo = false
|
||||
|
||||
###
|
||||
|
|
|
@ -28,7 +28,7 @@ func (c *Config) New(defaultOutput io.Writer) (*zap.Logger, error) {
|
|||
// If the format is empty or auto, then set the format depending
|
||||
// on whether or not a terminal is present.
|
||||
if format == "" || format == "auto" {
|
||||
if isTerminal(w) {
|
||||
if IsTerminal(w) {
|
||||
format = "console"
|
||||
} else {
|
||||
format = "logfmt"
|
||||
|
@ -71,7 +71,8 @@ func newEncoderConfig() zapcore.EncoderConfig {
|
|||
return config
|
||||
}
|
||||
|
||||
func isTerminal(w io.Writer) bool {
|
||||
// IsTerminal checks if w is a file and whether it is an interactive terminal session.
|
||||
func IsTerminal(w io.Writer) bool {
|
||||
if f, ok := w.(interface {
|
||||
Fd() uintptr
|
||||
}); ok {
|
||||
|
|
Loading…
Reference in New Issue