-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Format Logs and add timestamp to logging output option #5898
Changes from 8 commits
30dd342
5b0e10f
e1a74f5
9cd0982
3c44a9b
778f806
6a85745
5c275c7
fb25f9d
b6550f8
0d15b4d
f18b565
c06fec2
31381df
59c4c3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1363,3 +1363,37 @@ func TestDatabaseFlags(t *testing.T) { | |
}) | ||
} | ||
} | ||
|
||
func TestCheckAndSetDefaults(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The name of the test method does not hint that it has anything to do with the text formatter type. |
||
tests := []struct { | ||
comment string | ||
formatConfig []string | ||
hasError bool | ||
}{ | ||
{ | ||
comment: "invalid key (does not exist)", | ||
formatConfig: []string{"level", "invalid key"}, | ||
hasError: true, | ||
quinqu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
{ | ||
comment: "valid keys and formatting", | ||
formatConfig: []string{"level", "component", "message"}, | ||
hasError: false, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.comment, func(t *testing.T) { | ||
formatter := &textFormatter{ | ||
InitFormat: tt.formatConfig, | ||
} | ||
err := formatter.CheckAndSetDefaults() | ||
if tt.hasError { | ||
require.Error(t, err) | ||
} else { | ||
require.NoError(t, err) | ||
} | ||
}) | ||
} | ||
|
||
} | ||
quinqu marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -459,6 +459,8 @@ 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 defines the format in which each log line will be outputted. Example format: [timestamp, component, message] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
hence I would store all known fields in a variable ( |
||||||
Format []string `yaml:"format,omitempty"` | ||||||
} | ||||||
|
||||||
// Global is 'teleport' (global) section of the config file | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message