Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion internal/watcher/instance/nginx_config_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ func (ncp *NginxConfigParser) createNginxConfigContext(
if !ncp.ignoreLog(directive.Args[0]) {
errorLog := ncp.errorLog(directive.Args[0], ncp.errorLogDirectiveLevel(directive))
nginxConfigContext.ErrorLogs = append(nginxConfigContext.ErrorLogs, errorLog)
} else {
slog.WarnContext(ctx, fmt.Sprintf("Currently error log outputs to %s. Log monitoring "+
"is disabled while applying a config; "+"log errors to file to enable error monitoring",
directive.Args[0]), "error_log", directive.Args[0])
}
case "root":
rootFiles := ncp.rootFiles(ctx, directive.Args[0])
Expand Down Expand Up @@ -185,7 +189,7 @@ func (ncp *NginxConfigParser) createNginxConfigContext(

func (ncp *NginxConfigParser) ignoreLog(logPath string) bool {
logLower := strings.ToLower(logPath)
ignoreLogs := []string{"off", "/dev/stderr", "/dev/stdout", "/dev/null"}
ignoreLogs := []string{"off", "/dev/stderr", "/dev/stdout", "/dev/null", "stderr", "stdout"}

if strings.HasPrefix(logLower, "syslog:") || slices.Contains(ignoreLogs, logLower) {
return true
Expand Down
14 changes: 14 additions & 0 deletions internal/watcher/instance/nginx_config_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,20 @@ func TestNginxConfigParser_ignoreLog(t *testing.T) {
expected: false,
expectedLog: "Log being read is outside of allowed directories",
},
{
name: "Test 10: log stderr",
logPath: "stderr",
excludeLogs: []string{},
expected: true,
expectedLog: "",
},
{
name: "Test 11: log stdout",
logPath: "stdout",
excludeLogs: []string{},
expected: true,
expectedLog: "",
},
}

for _, test := range tests {
Expand Down