webmafia/fluentlog

Fluent Forward logger for PHP

Installs: 24

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/webmafia/fluentlog

v0.3.1 2025-12-09 09:43 UTC

This package is auto-updated.

Last update: 2025-12-09 09:43:53 UTC


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";