@@ -1002,7 +1002,37 @@ func FuzzRequest(f *testing.F) {
10021002 // Headers should always be present even if empty
10031003 assert .Contains (t , body , fmt .Sprintf ("[CONTENT_TYPE] => %s" , fuzzedString ))
10041004 assert .Contains (t , body , fmt .Sprintf ("[HTTP_FUZZED] => %s" , fuzzedString ))
1005-
10061005 }, & testOptions {workerScript : "request-headers.php" })
10071006 })
10081007}
1008+
1009+ func TestFrankenPHPLog (t * testing.T ) {
1010+ var buf bytes.Buffer
1011+ handler := slog .NewTextHandler (& buf , & slog.HandlerOptions {Level : slog .LevelDebug })
1012+ logger := slog .New (handler )
1013+
1014+ runTest (t , func (handler func (http.ResponseWriter , * http.Request ), _ * httptest.Server , i int ) {
1015+ body , _ := testGet ("http://example.com/logging.php" , handler , t )
1016+ assert .Empty (t , body )
1017+ }, & testOptions {
1018+ logger : logger ,
1019+ nbParallelRequests : 1 ,
1020+ })
1021+
1022+ logOutput := buf .String ()
1023+
1024+ for description , needle := range map [string ]string {
1025+ "should contains 'emerg' log" : "level=ERROR msg=\" testing emerg as ERROR\" syslog_level=emerg\n " ,
1026+ "should contains 'alert' log" : "level=ERROR msg=\" testing alert as ERROR\" syslog_level=alert\n " ,
1027+ "should contains 'crit' log" : "level=ERROR msg=\" testing crit as ERROR\" syslog_level=crit\n " ,
1028+ "should contains 'error' log" : "level=ERROR msg=\" testing error as ERROR\" syslog_level=err\n " ,
1029+ "should contains 'warn' log" : "level=WARN msg=\" testing warning as WARN\" syslog_level=warning\n " ,
1030+ "should contains 'notice' log" : "level=INFO msg=\" testing notice as INFO\" syslog_level=notice\n " ,
1031+ "should contains 'info' log" : "level=INFO msg=\" testing info as INFO\" syslog_level=info\n " ,
1032+ "should contains 'debug' log" : "level=DEBUG msg=\" testing debug as DEBUG\" syslog_level=debug\n " ,
1033+ } {
1034+ assert .Contains (t , logOutput ,
1035+ needle ,
1036+ description )
1037+ }
1038+ }
0 commit comments