@@ -1013,7 +1013,35 @@ func FuzzRequest(f *testing.F) {
10131013 // Headers should always be present even if empty
10141014 assert .Contains (t , body , fmt .Sprintf ("[CONTENT_TYPE] => %s" , fuzzedString ))
10151015 assert .Contains (t , body , fmt .Sprintf ("[HTTP_FUZZED] => %s" , fuzzedString ))
1016-
10171016 }, & testOptions {workerScript : "request-headers.php" })
10181017 })
10191018}
1019+
1020+ func TestFrankenPHPLog (t * testing.T ) {
1021+ var buf bytes.Buffer
1022+ handler := slog .NewTextHandler (& buf , & slog.HandlerOptions {Level : slog .LevelDebug })
1023+ logger := slog .New (handler )
1024+
1025+ runTest (t , func (handler func (http.ResponseWriter , * http.Request ), _ * httptest.Server , i int ) {
1026+ body , _ := testGet ("http://example.com/logging.php" , handler , t )
1027+ assert .Empty (t , body )
1028+ }, & testOptions {
1029+ logger : logger ,
1030+ nbParallelRequests : 1 ,
1031+ })
1032+
1033+ logOutput := buf .String ()
1034+
1035+ for level , needle := range map [string ]string {
1036+ "emerg" : "level=ERROR msg=\" testing emerg as ERROR\" syslog_level=emerg\n " ,
1037+ "alert" : "level=ERROR msg=\" testing alert as ERROR\" syslog_level=alert\n " ,
1038+ "crit" : "level=ERROR msg=\" testing crit as ERROR\" syslog_level=crit\n " ,
1039+ "error" : "level=ERROR msg=\" testing error as ERROR\" syslog_level=err\n " ,
1040+ "warn" : "level=WARN msg=\" testing warning as WARN\" syslog_level=warning\n " ,
1041+ "notice" : "level=INFO msg=\" testing notice as INFO\" syslog_level=notice\n " ,
1042+ "info" : "level=INFO msg=\" testing info as INFO\" syslog_level=info\n " ,
1043+ "debug" : "level=DEBUG msg=\" testing debug as DEBUG\" syslog_level=debug\n " ,
1044+ } {
1045+ assert .Containsf (t , logOutput , needle , "should contains %q log" , level )
1046+ }
1047+ }
0 commit comments