定制 thinkfluent/runphp-monolog-formatter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

thinkfluent/runphp-monolog-formatter

Composer 安装命令:

composer require thinkfluent/runphp-monolog-formatter

包简介

Monolog JSON formatter for runphp / Google Cloud Run Toolkit

README 文档

README

This produces correctly formatted JSON log messages that are automatically parsed by Google Cloud Logging.

Designed to work with RunPHP Serverless Toolkit, but can also run standalone.

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

Monolog Version Compatibility

Monolog has changes in v3.x that are not backwards compatible with v2.x.

  • For Monolog 1 or 2, use version ^1.0 of this package.
  • For Monolog 3, use version ^2.0 of this package.

Example Usage

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

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

In this sample we use applyInGoogleCloudContext() to only apply the JSON formatter when running in Google Cloud.

Locally, this will log a more human-readable format.

Please Note the auto-detection of GCP relies on code in from https://github.com/thinkfluent/runphp. If you're using this formatter outside of RunPHP images, you'll have to implement your own detection.

统计信息

  • 总下载量: 1.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固