Methods |
public
|
registerStdioTargets(): $this
Register STDOUT and STDERR to receive console output if running on the
command line
Register STDOUT and STDERR to receive console output if running on the
command line
- Errors and warnings are written to
STDERR
- Informational messages are written to
STDOUT
- Debug messages are ignored unless environment variable
DEBUG is set
Implemented by
|
#
|
public
|
registerStderrTarget(): $this
Register STDERR to receive console output if running on the command line
Register STDERR to receive console output if running on the command line
- Errors, warnings and informational messages are written to
STDERR
- Debug messages are ignored unless environment variable
DEBUG is set
Implemented by
|
#
|
public
|
registerTarget(ConsoleTargetInterface $target, array<MessageLevel::*> $levels = MessageLevelGroup::ALL): $this
Register a target to receive console output
Register a target to receive console output
Implemented by
|
#
|
public
|
deregisterTarget(ConsoleTargetInterface $target): $this
Deregister and close a registered target
Deregister and close a registered target
If $target is registered with the writer, it is deregistered and closed
via {@see ConsoleTargetInterface::close()}, otherwise calling this method
has no effect.
Implemented by
|
#
|
public
|
getTargets(
MessageLevel::*|null $level = null,
int-mask-of<ConsoleTargetTypeFlag::*> $flags = 0,
): ConsoleTargetInterface[]
Get a list of registered targets, optionally filtered by level and type
Get a list of registered targets, optionally filtered by level and type
Implemented by
|
#
|
public
|
setTargetPrefix(?string $prefix, int-mask-of<ConsoleTargetTypeFlag::*> $flags = 0): $this
Set or unset the prefix applied to each line of output by any registered
targets that implement…
Set or unset the prefix applied to each line of output by any registered
targets that implement ConsoleTargetPrefixInterface
Implemented by
|
#
|
public
|
getWidth(MessageLevel::* $level = MessageLevel::INFO): ?int
Get the width of a registered target in columns
Get the width of a registered target in columns
Returns {@see ConsoleTargetInterface::getWidth()} from whichever is found
first:
- the first TTY target registered with the given level
- the first
STDOUT or STDERR target registered with the given level
- the first target registered with the given level
- the target returned by {@see getStderrTarget()} if backed by a TTY
- the target returned by {@see getStdoutTarget()}
Implemented by
|
#
|
public
|
getFormatter(MessageLevel::* $level = MessageLevel::INFO): ConsoleFormatterInterface
Get an output formatter for a registered target
Get an output formatter for a registered target
Returns {@see ConsoleTargetInterface::getFormatter()} from the same
target as {@see ConsoleWriterInterface::getWidth()}.
Implemented by
|
#
|
public
|
getLogger(): LoggerInterface
Get a PSR-3 logger backed by the writer
Get a PSR-3 logger backed by the writer
Implemented by
|
#
|
public
|
getStdoutTarget(): ConsoleTargetStreamInterface
Get a target for STDOUT, creating an unregistered one if necessary
Get a target for STDOUT, creating an unregistered one if necessary
Implemented by
|
#
|
public
|
getStderrTarget(): ConsoleTargetStreamInterface
Get a target for STDERR, creating an unregistered one if necessary
Get a target for STDERR, creating an unregistered one if necessary
Implemented by
|
#
|
public
|
getErrorCount(): int
Get the number of error messages recorded by the writer so far
Get the number of error messages recorded by the writer so far
Implemented by
|
#
|
public
|
getWarningCount(): int
Get the number of warning messages recorded by the writer so far
Get the number of warning messages recorded by the writer so far
Implemented by
|
#
|
public
|
escape(string $string): string
Escape a string so it can be safely used in a console message
Escape a string so it can be safely used in a console message
Implemented by
|
#
|
public
|
error(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, bool $count = true): $this
Print "! $msg1 $msg2" with level ERROR
Print "! $msg1 $msg2" with level ERROR
Implemented by
|
#
|
public
|
errorOnce(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, bool $count = true): $this
Print "! $msg1 $msg2" with level ERROR once per run
Print "! $msg1 $msg2" with level ERROR once per run
Implemented by
|
#
|
public
|
warn(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, bool $count = true): $this
Print "^ $msg1 $msg2" with level WARNING
Print "^ $msg1 $msg2" with level WARNING
Implemented by
|
#
|
public
|
warnOnce(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, bool $count = true): $this
Print "^ $msg1 $msg2" with level WARNING once per run
Print "^ $msg1 $msg2" with level WARNING once per run
Implemented by
|
#
|
public
|
info(string $msg1, ?string $msg2 = null): $this
Print "➤ $msg1 $msg2" with level NOTICE
Print "➤ $msg1 $msg2" with level NOTICE
Implemented by
|
#
|
public
|
infoOnce(string $msg1, ?string $msg2 = null): $this
Print "➤ $msg1 $msg2" with level NOTICE once per run
Print "➤ $msg1 $msg2" with level NOTICE once per run
Implemented by
|
#
|
public
|
log(string $msg1, ?string $msg2 = null): $this
Print "- $msg1 $msg2" with level INFO
Print "- $msg1 $msg2" with level INFO
Implemented by
|
#
|
public
|
logOnce(string $msg1, ?string $msg2 = null): $this
Print "- $msg1 $msg2" with level INFO once per run
Print "- $msg1 $msg2" with level INFO once per run
Implemented by
|
#
|
public
|
debug(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, int $depth = 0): $this
Print ": <caller> $msg1 $msg2" with level DEBUG
Print ": $msg1 $msg2" with level DEBUG
Parameters
$depth |
To print your caller's name instead of your own, set
$depth to 1.
|
Implemented by
|
#
|
public
|
debugOnce(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, int $depth = 0): $this
Print ": <caller> $msg1 $msg2" with level DEBUG once per run
Print ": $msg1 $msg2" with level DEBUG once per run
Parameters
$depth |
To print your caller's name instead of your own, set
$depth to 1.
|
Implemented by
|
#
|
public
|
logProgress(string $msg1, ?string $msg2 = null): $this
Print "⠿ $msg1 $msg2" with level INFO to TTY targets without moving to
the next line
Print "⠿ $msg1 $msg2" with level INFO to TTY targets without moving to
the next line
This method can be called repeatedly to display progress updates without
disrupting other console messages or bloating output logs.
Implemented by
|
#
|
public
|
clearProgress(): $this
Print a "clear to end of line" control sequence with level INFO to TTY
targets with a logProgress() message
Print a "clear to end of line" control sequence with level INFO to TTY
targets with a logProgress() message
Implemented by
|
#
|
public
|
message(
string $msg1,
?string $msg2 = null,
MessageLevel::* $level = MessageLevel::INFO,
ConsoleMessageType::* $type = ConsoleMessageType::UNDECORATED,
?Throwable $ex = null,
bool $count = true,
): $this
Print "$msg1 $msg2" with prefix and formatting optionally based on $level
Print "$msg1 $msg2" with prefix and formatting optionally based on $level
Implemented by
|
#
|
public
|
messageOnce(
string $msg1,
?string $msg2 = null,
MessageLevel::* $level = MessageLevel::INFO,
ConsoleMessageType::* $type = ConsoleMessageType::UNDECORATED,
?Throwable $ex = null,
bool $count = true,
): $this
Print "$msg1 $msg2" with prefix and formatting optionally based on $level
once per run
Print "$msg1 $msg2" with prefix and formatting optionally based on $level
once per run
Implemented by
|
#
|
public
|
count(MessageLevel::* $level): $this
Record a message with level $level without printing anything
Record a message with level $level without printing anything
Implemented by
|
#
|
public
|
group(string $msg1, ?string $msg2 = null, ?string $endMsg1 = null, ?string $endMsg2 = null): $this
Increase the indentation level of messages and print "» $msg1 $msg2" with
level NOTICE
Increase the indentation level of messages and print "» $msg1 $msg2" with
level NOTICE
If $endMsg1 is not null , "« $endMsg1 $endMsg2" is printed with
level NOTICE when {@see groupEnd()} is called to close the group.
Implemented by
|
#
|
public
|
groupEnd(): $this
Close the nested message group most recently opened with group()
Close the nested message group most recently opened with group()
Implemented by
|
#
|
public
|
exception(
Throwable $exception,
MessageLevel::* $level = MessageLevel::ERROR,
MessageLevel::*|null $traceLevel = MessageLevel::DEBUG,
): $this
Print an exception's name and message with a given level, optionally
followed by its stack trace with a different level
Print an exception's name and message with a given level, optionally
followed by its stack trace with a different level
Parameters
$traceLevel |
If null , the exception's stack trace
is not printed.
|
Implemented by
|
#
|
public
|
summary(
string $finishedText = 'Command finished',
string $successText = 'without errors',
bool $withResourceUsage = false,
bool $withoutErrorCount = false,
bool $withStandardMessageType = false,
): $this
Print a "command finished" message with a summary of errors, warnings and
resource usage
Print a "command finished" message with a summary of errors, warnings and
resource usage
Implemented by
|
#
|
public
|
print(
string $msg,
MessageLevel::* $level = MessageLevel::INFO,
ConsoleMessageType::* $type = ConsoleMessageType::UNFORMATTED,
): $this
Print "$msg" to registered targets
Print "$msg" to registered targets
Implemented by
|
#
|
public
|
printOut(
string $msg,
MessageLevel::* $level = MessageLevel::INFO,
ConsoleMessageType::* $type = ConsoleMessageType::UNFORMATTED,
): $this
Print "$msg" to registered STDOUT or STDERR targets
Print "$msg" to registered STDOUT or STDERR targets
Implemented by
|
#
|
public
|
printTty(
string $msg,
MessageLevel::* $level = MessageLevel::INFO,
ConsoleMessageType::* $type = ConsoleMessageType::UNFORMATTED,
): $this
Print "$msg" to registered TTY targets
Print "$msg" to registered TTY targets
Implemented by
|
#
|
public
|
printStdout(
string $msg,
MessageLevel::* $level = MessageLevel::INFO,
ConsoleMessageType::* $type = ConsoleMessageType::UNFORMATTED,
): $this
Print "$msg" to STDOUT even if no STDOUT target is registered
Print "$msg" to STDOUT even if no STDOUT target is registered
Implemented by
|
#
|
public
|
printStderr(
string $msg,
MessageLevel::* $level = MessageLevel::INFO,
ConsoleMessageType::* $type = ConsoleMessageType::UNFORMATTED,
): $this
Print "$msg" to STDERR even if no STDERR target is registered
Print "$msg" to STDERR even if no STDERR target is registered
Implemented by
|
#
|