\Omega\Logging LoggerTrait

Logger trait.

The LoggerTrait provides implementations for logging messages across various log levels, simplifying the logging process by delegating to a single log() method. It defines several methods corresponding to different severity levels, as outlined by the PSR-3 specification for logging:

  • emergency(): Logs when the system is unusable.
  • alert(): Logs when action must be taken immediately.
  • critical(): Logs critical conditions
  • error(): Logs runtime errors that do not require immediate action but should be monitored.
  • warning(): Logs exceptional occurrences that are not errors.
  • notice(): Logs normal but significant events.
  • info(): Logs informational messages for general operational information.
  • debug(): Logs detailed debugging information for developers.

Each method accepts a string or Stringable message and an optional context array, then calls the log() method with the corresponding log level.

The log() method is abstract and must be implemented by the using class. It ensures flexibility, allowing the actual logging implementation to define how to handle different log levels. Additionally, it throws a LogArgumentException if invalid arguments are passed.

This trait standardizes logging behavior and promotes code reuse, enabling consistent logging practices throughout the application.

Summary

Methods
Properties
Constants
emergency
alert
critical
error
warning
notice
info
debug
log
No public properties found
No public constants found
No protected methods found
No protected properties found
No protected constants found
No private methods found
No private properties found
No private constants found

Methods

emergency()

emergency(string|\Stringable  $message, array  $context = []) : void

System is unusable.

Parameters

string|\Stringable $message

Holds the message for system is unusable.

array $context

Holds the context of message.

Returns

void —

alert()

alert(string|\Stringable  $message, array  $context = []) : void

Action must be taken immediately.

Parameters

string|\Stringable $message

Holds the message for action must be taken immediately.

array $context

Holds the context of message.

Returns

void —

critical()

critical(string|\Stringable  $message, array  $context = []) : void

Critical condition.

Parameters

string|\Stringable $message

Holds the message for critical condition.

array $context

Holds the context of message.

Returns

void —

error()

error(string|\Stringable  $message, array  $context = []) : void

Runtime errors that do not require immediate action but should typically be logged and monitored.

Parameters

string|\Stringable $message

Holds the message for runtime errors.

array $context

Holds the context of message.

Returns

void —

warning()

warning(string|\Stringable  $message, array  $context = []) : void

Exceptional occurrences that are not errors.

Parameters

string|\Stringable $message

Holds the message for exceptional errors.

array $context

Holds the context of message.

Returns

void —

notice()

notice(string|\Stringable  $message, array  $context = []) : void

Normal but significant events.

Parameters

string|\Stringable $message

Holds the message for normal but significant events.

array $context

Holds the context of message.

Returns

void —

info()

info(string|\Stringable  $message, array  $context = []) : void

Interesting events.

Parameters

string|\Stringable $message

Holds the message for interesting events.

array $context

Holds the context of message.

Returns

void —

debug()

debug(string|\Stringable  $message, array  $context = []) : void

Detailed debug information.

Parameters

string|\Stringable $message

Holds the message for detailed debug information.

array $context

Holds the context of message.

Returns

void —

log()

log(mixed  $level, string|\Stringable  $message, array  $context = []) : void

Logs with an arbitrary level.

Parameters

mixed $level

Holds the log level.

string|\Stringable $message

Holds the log message.

array $context

Holds the context of message.

Throws

\Omega\Logging\Exception\LogArgumentException

Returns

void —