class Log extends Mutator (View source)

Logs a value to a PSR-3 logger.

A default logger can be set using the setDefaultLogger method. If no logger is provided to the constructor, the default logger will be used. If no default logger is set, an exception will be thrown.

Traits

Methods

__construct(LoggerInterface $logger = null, string $prefix = '', string $level = LogLevel::DEBUG, array $context = [])

No description

mixed
__invoke(mixed $value)

Mutate the input value.

from  Mutator
static Log
make(LoggerInterface $logger = null, string $prefix = '', string $level = LogLevel::DEBUG, array $context = [])

No description

mixed
mutate(mixed $value)

Mutate the input value.

string
resolveStringInput(mixed $value)

No description

static LoggerInterface|null
setDefaultLogger(LoggerInterface|null $logger)

Set the default logger instance to use. If no logger is provided to the constructor, this logger will be used.

Details

__construct(LoggerInterface $logger = null, string $prefix = '', string $level = LogLevel::DEBUG, array $context = [])

No description

Parameters

LoggerInterface $logger

The logger to log to (optional). If not provided, the default logger will be used.

string $prefix

A prefix to prepend to the logged message (default: '').

string $level

The log level to use (default: LogLevel::DEBUG).

array $context

Additional context to pass to the logger (default: []).

final mixed __invoke(mixed $value)

Mutate the input value.

Parameters

mixed $value

Return Value

mixed

static Log make(LoggerInterface $logger = null, string $prefix = '', string $level = LogLevel::DEBUG, array $context = [])

No description

Parameters

LoggerInterface $logger

The logger to log to (optional). If not provided, the default logger will be used.

string $prefix

A prefix to prepend to the logged message (default: '').

string $level

The log level to use (default: LogLevel::DEBUG).

array $context

Additional context to pass to the logger (default: []).

Return Value

Log

mixed mutate(mixed $value)

Mutate the input value.

Parameters

mixed $value

Return Value

mixed

protected string resolveStringInput(mixed $value)

No description

Parameters

mixed $value

Return Value

string

static LoggerInterface|null setDefaultLogger(LoggerInterface|null $logger)

Set the default logger instance to use. If no logger is provided to the constructor, this logger will be used.

Parameters

LoggerInterface|null $logger

Return Value

LoggerInterface|null

The previous default logger instance (if any).