mirror of
https://github.com/dunglas/frankenphp.git
synced 2025-12-24 13:38:11 +08:00
feat: add support for structured logging with the frankenphp_log() PHP function (#1979)
As discussed in https://github.com/php/frankenphp/discussions/1961, there is no real way to pass a severity/level to any log handler offered by PHP that would make it to the FrankenPHP layer. This new function allows applications embedding FrankenPHP to integrate PHP logging into the application itself, thus offering a more streamlined experience. --------- Co-authored-by: Quentin Burgess <qutn.burgess@gmail.com> Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>
This commit is contained in:
@@ -2,6 +2,18 @@
|
||||
|
||||
/** @generate-class-entries */
|
||||
|
||||
/** @var int */
|
||||
const FRANKENPHP_LOG_LEVEL_DEBUG = -4;
|
||||
|
||||
/** @var int */
|
||||
const FRANKENPHP_LOG_LEVEL_INFO = 0;
|
||||
|
||||
/** @var int */
|
||||
const FRANKENPHP_LOG_LEVEL_WARN = 4;
|
||||
|
||||
/** @var int */
|
||||
const FRANKENPHP_LOG_LEVEL_ERROR = 8;
|
||||
|
||||
function frankenphp_handle_request(callable $callback): bool {}
|
||||
|
||||
function headers_send(int $status = 200): int {}
|
||||
@@ -36,3 +48,9 @@ function apache_response_headers(): array|bool {}
|
||||
* @param string|string[] $topics
|
||||
*/
|
||||
function mercure_publish(string|array $topics, string $data = '', bool $private = false, ?string $id = null, ?string $type = null, ?int $retry = null): string {}
|
||||
|
||||
/**
|
||||
* @param int $level The importance or severity of a log event. The higher the level, the more important or severe the event. For more details, see: https://pkg.go.dev/log/slog#Level
|
||||
* array<string, any> $context Values of the array will be converted to the corresponding Go type (if supported by FrankenPHP) and added to the context of the structured logs using https://pkg.go.dev/log/slog#Attr
|
||||
*/
|
||||
function frankenphp_log(string $message, int $level = 0, array $context = []): void {}
|
||||
|
||||
Reference in New Issue
Block a user