thinkfluent/runphp-monolog-formatter

Monolog JSON formatter for runphp / Google Cloud Run Toolkit

v1.1.0 2024-08-16 11:54 UTC

This package is auto-updated.

Last update: 2025-06-16 13:44:28 UTC


README

Designed to work with RunPHP Serverless Toolkit.

Advantages

Ensures the current "trace context" is applied to log entries - meaning logs can be grouped by request in the Google Cloud Logging console.

Install with Composer

composer require thinkfluent/runphp-monolog-formatter

Example Usage

use \Monolog\Logger;
use \Monolog\Handler\StreamHandler;
use \ThinkFluent\RunPHP\Logging\StackdriverJsonFormatter;

$handler = new StreamHandler('php://stderr', Logger::INFO);
StackdriverJsonFormatter::applyInGoogleCloudContext($handler);
$logger = new Logger('my-log');
$logger->pushHandler($handler);