Skip to content

Adding support for FrankenPHP logging#45

Open
kkozlik wants to merge 3 commits intopear:masterfrom
kkozlik:franken-log
Open

Adding support for FrankenPHP logging#45
kkozlik wants to merge 3 commits intopear:masterfrom
kkozlik:franken-log

Conversation

@kkozlik
Copy link
Copy Markdown

@kkozlik kkozlik commented Apr 16, 2026

Add FrankenPHP logging support via frankenphp_log()

This PR adds a new PEAR Log handler that routes log messages through FrankenPHP's native frankenphp_log() function, allowing PHP applications running under FrankenPHP to emit log output directly into FrankenPHP's own logging pipeline.

What's changed

  • New Log_Franken handler class that implements the standard PEAR Log interface
  • Log level mapping between PEAR Log priorities and FrankenPHP log levels
  • Throws a RuntimeException on initialization if frankenphp_log() is not available (i.e. outside of a FrankenPHP context), ensuring misconfiguration is caught early rather than silently producing no output

Why

When running PHP in FrankenPHP worker mode, error_log() and similar functions may not route output the way you'd expect. Using frankenphp_log() ensures that log messages are handled by FrankenPHP's Caddy-based logging system, respecting its formatting and routing configuration.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant