ez-php/logging

Logging module for the ez-php framework — structured logging with file, stdout, and null drivers

Maintainers

Package info

github.com/ez-php/logging

pkg:composer/ez-php/logging

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.2.0 2026-03-15 17:22 UTC

This package is auto-updated.

Last update: 2026-03-15 17:24:51 UTC


README

Logging module for the ez-php framework — structured logging with file, stdout, and null drivers.

CI

Requirements

  • PHP 8.5+
  • ez-php/framework ^0.1

Installation

composer require ez-php/logging

Setup

Register the service provider:

$app->register(\EzPhp\Logging\LogServiceProvider::class);

Configure the driver in config/logging.php:

return [
    'driver' => env('LOG_DRIVER', 'file'), // 'file' | 'stdout' | 'null'
    'path'   => env('LOG_PATH', 'storage/logs'),
];

Usage

use EzPhp\Logging\Log;

Log::debug('Cache miss', ['key' => 'users.all']);
Log::info('User registered', ['id' => 42]);
Log::warning('Rate limit approaching', ['remaining' => 5]);
Log::error('Payment failed', ['order' => 'ORD-99']);
Log::critical('Database unreachable');

// Generic level dispatch
Log::log('info', 'Something happened');

Drivers

Driver Description
file Appends to storage/logs/app-YYYY-MM-DD.log (daily rotation)
stdout debug/info/warning → stdout · error/critical → stderr
null Discards all entries — useful in tests

Exception Logging

LogServiceProvider automatically wraps the ExceptionHandler with LoggingExceptionHandler, so all unhandled exceptions are logged at error level before the response is rendered. No extra configuration needed.

Log Format

[2026-03-15 12:00:00] INFO: User registered {"id":42}
[2026-03-15 12:00:01] ERROR: Payment failed {"order":"ORD-99"}

License

MIT — Andreas Uretschnig