feat(cli): support fine-grained server log filtering (#8748)

This commit is contained in:
Ammar Bandukwala
2023-07-26 16:46:22 -05:00
committed by GitHub
parent 4e9e480cc6
commit 25e30c6f41
16 changed files with 148 additions and 60 deletions
+22 -9
View File
@@ -340,9 +340,10 @@ type SwaggerConfig struct {
}
type LoggingConfig struct {
Human clibase.String `json:"human" typescript:",notnull"`
JSON clibase.String `json:"json" typescript:",notnull"`
Stackdriver clibase.String `json:"stackdriver" typescript:",notnull"`
Filter clibase.StringArray `json:"log_filter" typescript:",notnull"`
Human clibase.String `json:"human" typescript:",notnull"`
JSON clibase.String `json:"json" typescript:",notnull"`
Stackdriver clibase.String `json:"stackdriver" typescript:",notnull"`
}
type DangerousConfig struct {
@@ -533,6 +534,16 @@ when required by your organization's security policy.`,
Group: &deploymentGroupNetworking,
YAML: "redirectToAccessURL",
}
logFilter := clibase.Option{
Name: "Log Filter",
Description: "Filter debug logs by matching against a given regex. Use .* to match all debug logs.",
Flag: "log-filter",
FlagShorthand: "l",
Env: "CODER_LOG_FILTER",
Value: &c.Logging.Filter,
Group: &deploymentGroupIntrospectionLogging,
YAML: "filter",
}
opts := clibase.OptionSet{
{
Name: "Access URL",
@@ -1159,7 +1170,7 @@ when required by your organization's security policy.`,
},
{
Name: "Capture Logs in Traces",
Description: "Enables capturing of logs as events in traces. This is useful for debugging, but may result in a very large amount of events being sent to the tracing backend which may incur significant costs. If the verbose flag was supplied, debug-level logs will be included.",
Description: "Enables capturing of logs as events in traces. This is useful for debugging, but may result in a very large amount of events being sent to the tracing backend which may incur significant costs.",
Flag: "trace-logs",
Env: "CODER_TRACE_LOGS",
Value: &c.Trace.CaptureLogs,
@@ -1249,12 +1260,14 @@ when required by your organization's security policy.`,
Flag: "verbose",
Env: "CODER_VERBOSE",
FlagShorthand: "v",
Value: &c.Verbose,
Group: &deploymentGroupIntrospectionLogging,
YAML: "verbose",
Annotations: clibase.Annotations{}.Mark(annotationExternalProxies, "true"),
Hidden: true,
UseInstead: []clibase.Option{logFilter},
Value: &c.Verbose,
Group: &deploymentGroupIntrospectionLogging,
YAML: "verbose",
Annotations: clibase.Annotations{}.Mark(annotationExternalProxies, "true"),
},
logFilter,
{
Name: "Human Log Location",
Description: "Output human-readable logs to a given file.",