LogsCommandResults
Provides reusable helpers for logging command outcomes and returning exit codes.
Description
Consuming commands stay focused on orchestration while this trait keeps the success, notice, and failure logging shape consistent across the command surface.
Properties
Caches the logger resolved for the consuming command.
Methods
Returns the logger configured for the consuming command.
Logs a failed command result and returns the failure exit code.
Logs a non-terminal command message unless structured JSON output is active.
Logs a successful command result and returns the success exit code.
Returns the logger configured for the consuming command.
public
getLogger() : LoggerInterface
Return values
Logs a failed command result and returns the failure exit code.
private
failure(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []][,
string|null
$file = null][,
int|null
$line = null]) : int
Parameters
$message
:
string
Description
the failure message
$input
:
InputInterface
Description
the originating command input
$context
:
array<string, mixed>
=
[]
Description
optional extra log context
$file
:
string|null
=
null
Description
the related file path when known
$line
:
int|null
=
null
Description
the related line when known
Return values
Logs a non-terminal command message unless structured JSON output is active.
private
log(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []][,
string
$logLevel = LogLevel::INFO]) : void
Parameters
$message
:
string
Description
the progress message
$input
:
InputInterface
Description
the originating command input
$context
:
array<string, mixed>
=
[]
Description
optional extra log context
$logLevel
:
string
=
LogLevel::INFO
Description
the PSR-3 log level used for the message
Logs a successful command result and returns the success exit code.
private
success(
string
$message, InputInterface
$input[,
array<string, mixed>
$context = []][,
string
$logLevel = LogLevel::INFO]) : int
Parameters
$message
:
string
Description
the success message
$input
:
InputInterface
Description
the originating command input
$context
:
array<string, mixed>
=
[]
Description
optional extra log context
$logLevel
:
string
=
LogLevel::INFO
Description
the PSR-3 log level used for the successful result