@@ -1002,7 +1002,35 @@ 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 level , needle := range map [string ]string {
1025+ "emerg" : "level=ERROR msg=\" testing emerg as ERROR\" syslog_level=emerg\n " ,
1026+ "alert" : "level=ERROR msg=\" testing alert as ERROR\" syslog_level=alert\n " ,
1027+ "crit" : "level=ERROR msg=\" testing crit as ERROR\" syslog_level=crit\n " ,
1028+ "error" : "level=ERROR msg=\" testing error as ERROR\" syslog_level=err\n " ,
1029+ "warn" : "level=WARN msg=\" testing warning as WARN\" syslog_level=warning\n " ,
1030+ "notice" : "level=INFO msg=\" testing notice as INFO\" syslog_level=notice\n " ,
1031+ "info" : "level=INFO msg=\" testing info as INFO\" syslog_level=info\n " ,
1032+ "debug" : "level=DEBUG msg=\" testing debug as DEBUG\" syslog_level=debug\n " ,
1033+ } {
1034+ assert .Containsf (t , logOutput , needle , "should contains %q log" , level )
1035+ }
1036+ }
0 commit comments