superbalist / monolog-google-cloud-json-formatter
A Monolog extension for formatting log entries for Google Cloud Logging
Installs: 328 990
Dependents: 0
Suggesters: 0
Security: 0
Stars: 15
Watchers: 34
Forks: 7
Open Issues: 1
Requires
- php: >=5.4.0
- monolog/monolog: ~1.0
This package is auto-updated.
Last update: 2024-07-30 01:02:55 UTC
README
This library works in conjunction with https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud
fluent-plugin-google-cloud is an output plugin for fluentd which sends logs to the Google Cloud Logging API.
This formatter outputs logs entries in json which the fluent-plugin-google-cloud application understands.
Installation
composer require superbalist/monolog-google-cloud-json-formatter
Usage
use Monolog\Logger; use Monolog\Handler\StreamHandler; use Superbalist\Monolog\Formatter; // create a handler $handler = new StreamHandler('path/to/your.log', Logger::WARNING); // use custom formatter in handler $handler->setFormatter(new GoogleCloudJsonFormatter()); // create a log channel $log = new Logger('name'); $log->pushHandler($handler); // add records to the log $log->addWarning('Foo'); $log->addError('Bar');