switon/log

PSR-3 logging with automatic categories, structured context, and category-aware level filtering for Switon Framework

Maintainers

Package info

github.com/switon-php/log

Documentation

pkg:composer/switon/log

Statistics

Installs: 6

Dependents: 3

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-06 13:43 UTC

This package is auto-updated.

Last update: 2026-06-07 03:41:32 UTC


README

Log CI PHP 8.3+

Switon's PSR-3 logger for application services that want automatic categories, structured context, per-category filtering, and low-setup defaults.

Highlights

  • Standard logger contract: LoggerInterface is the main logging contract.
  • Automatic category routing: log categories can be derived from the caller.
  • Structured context: placeholder interpolation and extra context stay structured.
  • Output backends: stdout, file, syslog, and memory sinks are available.
  • Category-aware filtering: Logger derives categories from the caller and applies per-category levels.

Installation

composer require switon/log

Quick Start

use Psr\Log\LoggerInterface;
use Switon\Core\Attribute\Autowired;

class UserService
{
    #[Autowired] protected LoggerInterface $logger;

    public function login(int $userId): void
    {
        $this->logger->info('User logged in', ['user_id' => $userId]);
    }
}

Docs: https://docs.switon.dev/latest/log

License

MIT.