\Omega\Logging LoggerAwareTrait

Logger aware trait.

The LoggerAwareTrait provides the implementation for objects that need to be logger-aware by allowing them to store and use a logger instance. This trait is part of the Omega Logging package and helps in injecting a logger into any class that uses it. It includes the following elements:

  • $logger: A protected property that stores an instance of the LoggerInterface. It is nullable, meaning an object can either have a logger instance assigned or none.

  • setLogger(LoggerInterface $logger): A method used to assign a logger instance to the object. This enables the object to log messages through the provided logger.

This trait is typically used in combination with the LoggerAwareInterface to ensure objects can accept and manage logger instances, promoting consistency in logging across different parts of the application.

Summary

Methods
Properties
Constants
setLogger
No public properties found
No public constants found
No protected methods found
logger
No protected constants found
No private methods found
No private properties found
No private constants found

Properties

$logger

$logger : \Omega\Logging\LoggerInterface|null

The logger instance.

Type

LoggerInterface|null — Holds the current logger instance.

Methods

setLogger()

setLogger(\Omega\Logging\LoggerInterface  $logger) : void

Sets a logger instance on the object.

Parameters

\Omega\Logging\LoggerInterface $logger

Returns

void —