diff --git a/docs/pages/config-reference.mdx b/docs/pages/config-reference.mdx index 0d2bbb32ce7..2352de988f0 100644 --- a/docs/pages/config-reference.mdx +++ b/docs/pages/config-reference.mdx @@ -56,11 +56,11 @@ teleport: # Logging configuration. Possible output values to disk via '/var/lib/teleport/teleport.log', # 'stdout', 'stderr' and 'syslog'. Possible severity values are INFO, WARN - # and ERROR (default). Possible format values include: timestamp, component, message, caller, and level. + # and ERROR (default). Possible format values include: timestamp, component, caller, and level. log: output: /var/lib/teleport/teleport.log severity: ERROR - format: [level, timestamp, component, message] + format: [level, timestamp, component, caller] # Configuration for the storage back-end used for the cluster state and the # audit log. Several back-end types are supported. See the "High Availability" diff --git a/lib/config/fileconf.go b/lib/config/fileconf.go index 33cec2f6865..b36215373eb 100644 --- a/lib/config/fileconf.go +++ b/lib/config/fileconf.go @@ -459,7 +459,7 @@ type Log struct { Output string `yaml:"output,omitempty"` // Severity defines how verbose the log will be. Possible valus are "error", "info", "warn" Severity string `yaml:"severity,omitempty"` - // Format lists the output fields from KnownFormatFields. Example format: [timestamp, component, message] + // Format lists the output fields from KnownFormatFields. Example format: [timestamp, component, caller] Format []string `yaml:"format,omitempty"` } diff --git a/lib/config/formatter.go b/lib/config/formatter.go index 06b10fdd0bf..bfe8744bd3c 100644 --- a/lib/config/formatter.go +++ b/lib/config/formatter.go @@ -27,6 +27,7 @@ import ( "strings" "time" + "github.com/gravitational/teleport/api/utils" "github.com/gravitational/trace" log "github.com/sirupsen/logrus" ) @@ -75,7 +76,6 @@ func (tf *textFormatter) CheckAndSetDefaults() error { // set log formatting if tf.LogFormat == nil { - tf.timestampEnabled = true tf.callerEnabled = true tf.LogFormat = KnownFormatFields.names() return nil @@ -85,11 +85,12 @@ func (tf *textFormatter) CheckAndSetDefaults() error { if err != nil { return trace.Wrap(err) } - if contains(res, timestampField) { + + if utils.SliceContainsStr(res, timestampField) { tf.timestampEnabled = true } - if contains(res, callerField) { + if utils.SliceContainsStr(res, callerField) { tf.callerEnabled = true } @@ -362,13 +363,3 @@ func parseInputFormat(formatInput []string) (result []string, err error) { } return result, nil } - -func contains(s []string, str string) bool { - for _, v := range s { - if v == str { - return true - } - } - - return false -}