phpnomad/logger

Maintainers

Package info

github.com/phpnomad/logger

Homepage

pkg:composer/phpnomad/logger

Statistics

Installs: 4 276

Dependents: 7

Suggesters: 0

Stars: 0

Open Issues: 1

1.2.0 2026-03-31 15:22 UTC

README

Latest Version Total Downloads PHP Version License

phpnomad/logger defines the logging contract used throughout PHPNomad applications. It ships the LoggerStrategy interface, the CanLogException trait, and the LoggerLevel constants, and nothing else. Implementations live in other packages or in your own application code, so you can swap logging destinations without touching the code that calls the logger.

Installation

composer require phpnomad/logger

Overview

The package provides a small, focused set of building blocks:

  • LoggerStrategy interface with eight level methods (emergency, alert, critical, error, warning, notice, info, debug) plus logException for structured exception logging.
  • CanLogException trait that implements logException by attaching the exception to context and dispatching to the configured level method (defaults to critical).
  • LoggerLevel constants for the eight level strings, matching PSR-3 conventions.
  • Zero runtime dependencies. The package is pure abstraction.
  • Pairs with phpnomad/core, which ships an event-broadcasting strategy and a static Logger facade. Transports like phpnomad/sentry-integration subscribe to those events in production builds.

Usage

Inject LoggerStrategy and call the appropriate level:

use PHPNomad\Logger\Interfaces\LoggerStrategy;

class OrderService
{
    public function __construct(private LoggerStrategy $logger) {}

    public function process(Order $order): void
    {
        $this->logger->info('Processing order', ['order_id' => $order->getId()]);
    }
}

Documentation

Full documentation for the logger package and the rest of PHPNomad lives at phpnomad.com.

License

MIT. See LICENSE.txt.