Index

tLogEmitter

MMO\core\classes · 1 symbol · generated 30 Sep 2026

trait

tLogEmitter

tLogEmitter.php:20

Implements MMO\core\interfaces\iLogEmitter: gives any class a full set of PSR-3 log-level methods (emergency/alert/critical/error/warning/notice/info/debug/log), each gated by a per-instance verbosity bitmask (iLogLevel for the level constants). Every method dispatches a MMO\core\events\Log event.

trait MMO\core\classes\tLogEmitter
Namespace
MMO\core\classes
NOTE: log()/emergency()/alert()/critical()/error()/warning()/notice()/info()/debug() are all declared `void` and cannot be changed to return the dispatched Log, even though one is created internally: `iLogEmitter extends \Psr\Log\LoggerInterface`, whose 9 methods are contractually `void` (that's what makes any iLogEmitter usable as a drop-in PSR-3 logger for third-party code). If you need the actual Log event, listen to `MMO\core\events\Log::AddListener()` directly, or use [`backtraces()`](https://mmoframework.fr/documentation/mmo.core/php/classes/tLogEmitter.md#tlogemitter-backtraces) which is free to return it.

Index

verbosity
alert($message, $context)Action must be taken immediately.
backtraces($message, $context)Force-log a message at INFO level together with a full stack trace/memory snapshot (iLogLevel::BACKTRACE), bypassing the verbosity mask entirely (any non-zero verbosity is enough to trigger it).
critical($message, $context)Critical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask.
debug($message, $context)Detailed debug information.
debugName()Human-readable identifier used as the default {origin} in this instance's log messages.
emergency($message, $context)System is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask.
error($message, $context)Runtime errors that do not require immediate action but should typically be logged and monitored.
getVerbosity()
info($message, $context)Interesting events. No-op if INFO is currently filtered out by the verbosity mask.
log($level, $message, $context)Logs with an arbitrary level.
notice($message, $context)Normal but significant events.
setVerbosity($verb)Set the current verbosity mask, replacing whatever it was before.
testVerbosity($level)Test whether a given level (or set of levels) is currently enabled by this instance's verbosity mask.
warning($message, $context)Exceptional occurrences that are not errors.

Properties1

verbosity

#[MMO\core\attributes\Serialize(order: -1000)] protected int $verbosity = 31
Type
int

Methods14

alert($message, $context)

tLogEmitter.php:121

Action must be taken immediately.

function alert(Stringable|string $message, array $context = []): voidExample: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.
$messageStringable | string
$context = []array
returnsvoid
$this->alert('payment gateway unreachable for 5 minutes.');

backtraces($message, $context)

tLogEmitter.php:234

Force-log a message at INFO level together with a full stack trace/memory snapshot (iLogLevel::BACKTRACE), bypassing the verbosity mask entirely (any non-zero verbosity is enough to trigger it).

function backtraces(string $message = ' -- TRACES -- ', array $context = []): void
$message = ' -- TRACES -- 'string
$context = []array
returnsvoid
$this->backtraces('unexpected state reached in {method}.', ['method' => __METHOD__]);

critical($message, $context)

tLogEmitter.php:138

Critical conditions. No-op if CRITICAL is currently filtered out by the verbosity mask.

function critical(Stringable|string $message, array $context = []): voidExample : Application component unavailable, unexpected exception.
$messageStringable | string
$context = []array
returnsvoid
$this->critical('unexpected {exception}.', ['exception' => $e]);

debug($message, $context)

tLogEmitter.php:219

Detailed debug information. No-op if DEBUG is currently filtered out by the verbosity mask.

function debug(Stringable|string $message, array $context = []): void
$messageStringable | string
$context = []array
returnsvoid
$this->debug('set stream [{stream}].', ['stream' => $stream]);

debugName()

tLogEmitter.php:30

Human-readable identifier used as the default {origin} in this instance's log messages.

function debugName(): stringOverride this in a class using the trait to show something more specific than the bare classname.
returnsstring

emergency($message, $context)

tLogEmitter.php:103

System is unusable. No-op if EMERGENCY is currently filtered out by the verbosity mask.

function emergency(Stringable|string $message, array $context = []): void
$messageStringable | string
$context = []array
returnsvoid
$this->emergency('database connection lost.');

error($message, $context)

tLogEmitter.php:154

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

function error(Stringable|string $message, array $context = []): voidNo-op if ERROR is currently filtered out by the verbosity mask.
$messageStringable | string
$context = []array
returnsvoid
$this->error('failed to write [{file}].', ['file' => $filename]);

getVerbosity()

tLogEmitter.php:38
function getVerbosity(): int
returnsintthe current verbosity, as a bitmask of iLogLevel::* constants
$this->getVerbosity() === (iLogLevel::ERROR_PLUS); // true if only errors/critical/alert/emergency are enabled

info($message, $context)

tLogEmitter.php:204

Interesting events. No-op if INFO is currently filtered out by the verbosity mask.

function info(Stringable|string $message, array $context = []): voidExample: User logs in, SQL logs.
$messageStringable | string
$context = []array
returnsvoid
$this->info('routing [{request}] ...', ['request' => $request]);

log($level, $message, $context)

tLogEmitter.php:81

Logs with an arbitrary level.

function log($level, Stringable|string $message, array $context = []): voidNOTE: $level is filtered against the current [`setVerbosity()`](https://mmoframework.fr/documentation/mmo.core/php/classes/tLogEmitter.md#tlogemitter-setverbosity): if the level is masked out, nothing is logged/dispatched at all. Return type is `void` (not the dispatched Log) to satisfy \Psr\Log\LoggerInterface.
$level
$messageStringable | string
$context = []arrayignored if $message is a Log
returnsvoid
$this->log(self::ERROR, 'disk usage at {percent}%.', ['percent' => 92]); $this->log('error', $caughtException); //string levels are resolved through \MMO\core\debug\flags()

notice($message, $context)

tLogEmitter.php:187

Normal but significant events. No-op if NOTICE is currently filtered out by the verbosity mask.

function notice(Stringable|string $message, array $context = []): void
$messageStringable | string
$context = []array
returnsvoid
$this->notice('-- START -- ({mode}): {time}', ['mode' => MMO_MODE, 'time' => date('r')]);

setVerbosity($verb)

tLogEmitter.php:64

Set the current verbosity mask, replacing whatever it was before.

function setVerbosity(string|int|null $verb = null): void
$verb = nullstring | int | nulla bitmask of iLogLevel::* constants, or a level name/expression resolved through \MMO\core\debug\flags() (e.g. 'error+' for iLogLevel::ERROR_PLUS)
returnsvoid
$this->setVerbosity(iLogLevel::WARNING_PLUS); // only log warnings and above $this->setVerbosity('all'); // log everything

testVerbosity($level)

tLogEmitter.php:50

Test whether a given level (or set of levels) is currently enabled by this instance's verbosity mask.

function testVerbosity(string|int $level): int
$levelstring | inta iLogLevel::* constant/bitmask, or a level name resolved through \MMO\core\debug\flags()
returnsintthe bits of $level that are currently enabled (0 if none of them are)
$this->testVerbosity(self::DEBUG); // non-zero if debug-level logging is currently enabled $this->testVerbosity('error'); // same, using the string form

warning($message, $context)

tLogEmitter.php:172

Exceptional occurrences that are not errors. No-op if WARNING is currently filtered out by the verbosity mask.

function warning(Stringable|string $message, array $context = []): voidExample: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
$messageStringable | string
$context = []array
returnsvoid
$this->warning('{count} logs were dropped.', ['count' => 3]);