Methods |
public
|
__construct()
|
#
|
public
|
getLogger(): LoggerInterface
Get a PSR-3 logger backed by the writer
Get a PSR-3 logger backed by the writer
Implements
|
#
|
public
|
unload(): void
Close the object's underlying resources
Close the object's underlying resources
Implements
|
#
|
public
|
registerStdioTargets()
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
Implements
|
#
|
public
|
registerStderrTarget()
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
Implements
|
#
|
public
|
registerTarget(ConsoleTargetInterface $target, array $levels = MessageLevelGroup::ALL)
Register a target to receive console output
Register a target to receive console output
Implements
|
#
|
public
|
deregisterTarget(ConsoleTargetInterface $target)
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.
Implements
|
#
|
public
|
getTargets(?int $level = null, int $flags = 0): array
Get a list of registered targets, optionally filtered by level and type
Get a list of registered targets, optionally filtered by level and type
Implements
|
#
|
public
|
setTargetPrefix(?string $prefix, int $flags = 0)
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
Implements
|
#
|
public
|
getWidth(int $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()}
Implements
|
#
|
public
|
getFormatter(int $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()}.
Implements
|
#
|
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
Implements
|
#
|
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
Implements
|
#
|
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
Implements
|
#
|
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
Implements
|
#
|
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
Implements
|
#
|
public
|
summary(
string $finishedText = 'Command finished',
string $successText = 'without errors',
bool $withResourceUsage = false,
bool $withoutErrorCount = false,
bool $withStandardMessageType = false,
)
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
Implements
|
#
|
public
|
print(string $msg, int $level = MessageLevel::INFO, int $type = ConsoleMessageType::UNFORMATTED)
Print "$msg" to registered targets
Print "$msg" to registered targets
Implements
|
#
|
public
|
printOut(string $msg, int $level = MessageLevel::INFO, int $type = ConsoleMessageType::UNFORMATTED)
Print "$msg" to registered STDOUT or STDERR targets
Print "$msg" to registered STDOUT or STDERR targets
Implements
|
#
|
public
|
printTty(string $msg, int $level = MessageLevel::INFO, int $type = ConsoleMessageType::UNFORMATTED)
Print "$msg" to registered TTY targets
Print "$msg" to registered TTY targets
Implements
|
#
|
public
|
printStdout(string $msg, int $level = MessageLevel::INFO, int $type = ConsoleMessageType::UNFORMATTED)
Print "$msg" to STDOUT even if no STDOUT target is registered
Print "$msg" to STDOUT even if no STDOUT target is registered
Implements
|
#
|
public
|
printStderr(string $msg, int $level = MessageLevel::INFO, int $type = ConsoleMessageType::UNFORMATTED)
Print "$msg" to STDERR even if no STDERR target is registered
Print "$msg" to STDERR even if no STDERR target is registered
Implements
|
#
|
public
|
message(
string $msg1,
?string $msg2 = null,
int $level = MessageLevel::INFO,
int $type = ConsoleMessageType::UNDECORATED,
?Throwable $ex = null,
bool $count = true,
)
Print "$msg1 $msg2" with prefix and formatting optionally based on $level
Print "$msg1 $msg2" with prefix and formatting optionally based on $level
Implements
|
#
|
public
|
messageOnce(
string $msg1,
?string $msg2 = null,
int $level = MessageLevel::INFO,
int $type = ConsoleMessageType::UNDECORATED,
?Throwable $ex = null,
bool $count = true,
)
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
Implements
|
#
|
public
|
count($level)
Record a message with level $level without printing anything
Record a message with level $level without printing anything
Implements
|
#
|
public
|
error(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, bool $count = true)
Print "! $msg1 $msg2" with level ERROR
Print "! $msg1 $msg2" with level ERROR
Implements
|
#
|
public
|
errorOnce(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, bool $count = true)
Print "! $msg1 $msg2" with level ERROR once per run
Print "! $msg1 $msg2" with level ERROR once per run
Implements
|
#
|
public
|
warn(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, bool $count = true)
Print "^ $msg1 $msg2" with level WARNING
Print "^ $msg1 $msg2" with level WARNING
Implements
|
#
|
public
|
warnOnce(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, bool $count = true)
Print "^ $msg1 $msg2" with level WARNING once per run
Print "^ $msg1 $msg2" with level WARNING once per run
Implements
|
#
|
public
|
info(string $msg1, ?string $msg2 = null)
Print "➤ $msg1 $msg2" with level NOTICE
Print "➤ $msg1 $msg2" with level NOTICE
Implements
|
#
|
public
|
infoOnce(string $msg1, ?string $msg2 = null)
Print "➤ $msg1 $msg2" with level NOTICE once per run
Print "➤ $msg1 $msg2" with level NOTICE once per run
Implements
|
#
|
public
|
log(string $msg1, ?string $msg2 = null)
Print "- $msg1 $msg2" with level INFO
Print "- $msg1 $msg2" with level INFO
Implements
|
#
|
public
|
logOnce(string $msg1, ?string $msg2 = null)
Print "- $msg1 $msg2" with level INFO once per run
Print "- $msg1 $msg2" with level INFO once per run
Implements
|
#
|
public
|
logProgress(string $msg1, ?string $msg2 = null)
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.
Implements
|
#
|
public
|
clearProgress()
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
Implements
|
#
|
public
|
debug(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, int $depth = 0)
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.
|
Implements
|
#
|
public
|
debugOnce(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, int $depth = 0)
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.
|
Implements
|
#
|
public
|
group(string $msg1, ?string $msg2 = null, ?string $endMsg1 = null, ?string $endMsg2 = null)
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.
Implements
|
#
|
public
|
groupEnd()
Close the nested message group most recently opened with group()
Close the nested message group most recently opened with group()
Implements
|
#
|
public
|
exception(Throwable $exception, int $level = MessageLevel::ERROR, ?int $traceLevel = MessageLevel::DEBUG)
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.
|
Implements
|
#
|