Search by

duncan3dc / logger-aware-trait

duncan3dc

A PSR-3 trait allowing any class to easily add logger support

Package info

github.com/duncan3dc/logger-aware-trait

pkg:composer/duncan3dc/logger-aware-trait

Statistics

Installs: 35 466

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

1.3.0 2026-06-05 11:54 UTC

This package is auto-updated.

Last update: 2026-10-12 10:23:04 UTC


README

A PSR-3 trait allowing any class to easily add logger support

release build coverage

Installing

The recommended method of installing this library is via Composer.

Run the following command from your project root:

$ composer require duncan3dc/logger-aware-trait

Setup

Simply apply the trait to your classes:

use duncan3dc\Log\LoggerAwareTrait;

class MyClass
{
    use LoggerAwareTrait;
}

Now the class will have a getLogger() method that you can safely call.
If a logger has been injected using setLogger() then that logger will be provided, otherwise a NullLogger will be used instead.

Changelog

A Changelog has been available since the beginning of time

Where to get help

Found a bug? Got a question? Just not sure how something works?
Please create an issue and I'll do my best to help out.
Alternatively you can connect with me on LinkedIn