diff --git a/caddy/caddy_test.go b/caddy/caddy_test.go index 5f95c0ab3..e359e3d4b 100644 --- a/caddy/caddy_test.go +++ b/caddy/caddy_test.go @@ -1472,3 +1472,31 @@ func TestDd(t *testing.T) { "dump123", ) } + +func TestLog(t *testing.T) { + tester := caddytest.NewTester(t) + tester.InitServer(` + { + skip_install_trust + admin localhost:2999 + } + + http://localhost:`+testPort+` { + log { + output stdout + format json + } + + root ../testdata + php_server { + worker ../testdata/log-frankenphp_log.php + } + } + `, "caddyfile") + + tester.AssertGetResponse( + "http://localhost:"+testPort+"/log-frankenphp_log.php?i=0", + http.StatusOK, + "", + ) +} diff --git a/frankenphp.c b/frankenphp.c index a6772a86e..d048e576b 100644 --- a/frankenphp.c +++ b/frankenphp.c @@ -554,10 +554,10 @@ PHP_FUNCTION(frankenphp_log) { zend_long level = 0; zval *context = NULL; - ZEND_PARSE_PARAMETERS_START(2, 3) + ZEND_PARSE_PARAMETERS_START(1, 3) Z_PARAM_STR(message) - Z_PARAM_LONG(level) Z_PARAM_OPTIONAL + Z_PARAM_LONG(level) Z_PARAM_ARRAY(context) ZEND_PARSE_PARAMETERS_END(); diff --git a/frankenphp_test.go b/frankenphp_test.go index d5368d145..8c6f3c90d 100644 --- a/frankenphp_test.go +++ b/frankenphp_test.go @@ -447,6 +447,7 @@ func testLog_frankenphp_log(t *testing.T, opts *testOptions) { logs := buf.String() for _, message := range []string{ + `level=INFO msg="default level message"`, fmt.Sprintf(`level=DEBUG msg="some debug message %d" "key int"=1`, i), fmt.Sprintf(`level=INFO msg="some info message %d" "key string"=string`, i), fmt.Sprintf(`level=WARN msg="some warn message %d"`, i), diff --git a/testdata/log-frankenphp_log.php b/testdata/log-frankenphp_log.php index ab587f6e6..244a6f215 100644 --- a/testdata/log-frankenphp_log.php +++ b/testdata/log-frankenphp_log.php @@ -2,6 +2,8 @@ require_once __DIR__.'/_executor.php'; +frankenphp_log("default level message"); + return function () { frankenphp_log("some debug message {$_GET['i']}", FRANKENPHP_LOG_LEVEL_DEBUG, [ "key int" => 1,