webmafia/fluentlog 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

webmafia/fluentlog

最新稳定版本:v0.4.1

Composer 安装命令:

composer require webmafia/fluentlog

包简介

Fluent Forward logger for PHP

README 文档

README

This is a PHP version of Fluentlog, with three important differences:

  1. Writing logs is not asynchronous.
  2. Written logs are not buffered.
  3. Written logs are not retried.

For this reason it's highly recommended to write to a local log collector (preferably FluentBit).

Installation

composer require webmafia/fluentlog

Usage example

<?php

use Webmafia\Fluentlog\Logger;
use Webmafia\Fluentlog\TcpClient;
use Webmafia\Fluentlog\TextClient;

require_once('../vendor/autoload.php');

$env = parse_ini_file('.env');

$client = new TcpClient(
	host: $env['HOST'],
	useTls: !empty($env['TLS']),
    sharedKey: $env['SHARED_KEY'],
    username: $env['USERNAME'],
    password: $env['PASSWORD']
);

// $client = new TextClient(fopen('php://output', 'w'));

$logger = new Logger($client, 'php');
$start = microtime(true);

for($i = 0; $i < 10; $i++) {
	echo $logger->info('hello from php %d', $i) . "\n";
}

$end = microtime(true);
$dur = $end - $start;
echo 'Done in ' . $dur . ' seconds' . "\n";

Error handler

There is also (since v0.4.0) a method on the logger that registers an error handler, that will catch and handle any error (fatals, uncatched exceptions, syntax errors, etc). Remember to call the method as early as possible in your application, as it won't catch any error that occurs before registration.

<?php

$logger = new Logger($client, 'php');

// <- Any error that occurs here will NOT be handled.

$logger->registerErrorHandler();

error_log('This will NOT be handled either, as error handlers do not catch these messages');

throw new Exception('An uncatched exception that WILL be handled');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2025-11-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固