Skip to content

Commit b4d2416

Browse files
committed
add warning and exclude stdout and stderr
1 parent e881bd2 commit b4d2416

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

internal/watcher/instance/nginx_config_parser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ func (ncp *NginxConfigParser) createNginxConfigContext(
130130
errorLog := ncp.errorLog(directive.Args[0], ncp.errorLogDirectiveLevel(directive))
131131
nginxConfigContext.ErrorLogs = append(nginxConfigContext.ErrorLogs, errorLog)
132132
} else {
133-
slog.WarnContext(ctx, fmt.Sprintf("Error log outputs to %s. Unable to monitor logs during "+
134-
"config apply, log errors to file to enable error monitoring", directive.Args[0]),
135-
"error_log", directive.Args[0])
133+
slog.WarnContext(ctx, fmt.Sprintf("Currently error log outputs to %s. Log monitoring "+
134+
"is disabled while applying a config; "+"log errors to file to enable error monitoring",
135+
directive.Args[0]), "error_log", directive.Args[0])
136136
}
137137
case "root":
138138
rootFiles := ncp.rootFiles(ctx, directive.Args[0])

internal/watcher/instance/nginx_config_parser_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,20 @@ func TestNginxConfigParser_ignoreLog(t *testing.T) {
927927
expected: false,
928928
expectedLog: "Log being read is outside of allowed directories",
929929
},
930+
{
931+
name: "Test 10: log stderr",
932+
logPath: "stderr",
933+
excludeLogs: []string{},
934+
expected: true,
935+
expectedLog: "",
936+
},
937+
{
938+
name: "Test 11: log stdout",
939+
logPath: "stdout",
940+
excludeLogs: []string{},
941+
expected: true,
942+
expectedLog: "",
943+
},
930944
}
931945

932946
for _, test := range tests {

0 commit comments

Comments
 (0)