amphp/log

Non-blocking logging for PHP based on Amp, Revolt, and Monolog.

Package info

github.com/amphp/log

pkg:composer/amphp/log

Fund package maintenance!

amphp

Statistics

Installs: 2 833 678

Dependents: 96

Suggesters: 1

Stars: 40

Open Issues: 3

v2.0.0 2023-08-05 18:59 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT bf1562b8a18a3f30efa069ed740f412ac70a8a6c

  • Aaron Piotrowski <aaron.woop@trowski.com>
  • Niklas Keller <me.woop@kelunik.com>

logloggingloggerasyncnon-blockingampamphp

This package is auto-updated.

Last update: 2026-06-06 01:05:18 UTC


README

AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind. amphp/log provides a non-blocking stream handler for monolog/monolog.

👁 Release
👁 License

Installation

This package can be installed as a Composer dependency.

composer require amphp/log

Usage

<?php

use Amp\ByteStream;
use Amp\Log\ConsoleFormatter;
use Amp\Log\StreamHandler;
use Monolog\Logger;

require dirname(__DIR__) . '/vendor/autoload.php';

// You can also log to a file using amphp/file:
// $handler = new StreamHandler(File\openFile(__DIR__ . '/example.log', 'w'));

// Here we'll log to the standard output stream of the current process:
$handler = new StreamHandler(ByteStream\getStdout());
$handler->setFormatter(new ConsoleFormatter);

$logger = new Logger('main');
$logger->pushHandler($handler);

$logger->debug("Hello, world!");
$logger->info("Hello, world!");
$logger->notice("Hello, world!");
$logger->error("Hello, world!");
$logger->alert("Hello, world!");