Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
28 changes: 28 additions & 0 deletions caddy/caddy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
"",
)
}
4 changes: 2 additions & 2 deletions frankenphp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
1 change: 1 addition & 0 deletions frankenphp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions testdata/log-frankenphp_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading