Methods |
public
|
__construct()
|
#
|
public
|
unload(): void
Close the object's underlying resources
Close the object's underlying resources
Implements
|
#
|
public
|
logger(): LoggerInterface
Get a PSR-3 logger backed by the console
Get a PSR-3 logger backed by the console
Implements
|
#
|
public
|
registerTarget(TargetInterface $target, array $levels = Console::LEVELS_ALL)
Register a target to receive output with each of the given message levels
from the console
Register a target to receive output with each of the given message levels
from the console
Implements
|
#
|
public
|
deregisterTarget(TargetInterface $target)
Deregister a target if it is currently registered with the console
Deregister a target if it is currently registered with the console
Implements
|
#
|
public
|
registerStderrTarget(?bool $debug = null)
Register STDERR for console output if running on the command line
Register STDERR for console output if running on the command line
Messages with level LEVEL_DEBUG are written to STDERR if:
$debug is true , or
$debug is null and debug mode is enabled in the environment
Implements
|
#
|
public
|
registerStdioTargets(?bool $debug = null)
Register STDOUT and STDERR for console output if running on the command
line
Register STDOUT and STDERR for console output if running on the command
line
If the level of a message is LEVEL_WARNING or lower, it is written to
STDERR , otherwise it is written to STDOUT .
Messages with level LEVEL_DEBUG are written to STDOUT if:
$debug is true , or
$debug is null and debug mode is enabled in the environment
Implements
|
#
|
public
|
setPrefix(?string $prefix, int $targetFlags = 0)
Set or unset the prefix applied to each line of output by registered
targets that implement HasPrefix after optionally…
Set or unset the prefix applied to each line of output by registered
targets that implement HasPrefix after optionally filtering them by flag
Implements
|
#
|
public
|
getTargets(?int $level = null, int $targetFlags = 0): array
Get registered targets, optionally filtering them by message level and
flag
Get registered targets, optionally filtering them by message level and
flag
Implements
|
#
|
public
|
getStdoutTarget(): StreamTargetInterface
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(): StreamTargetInterface
Get a target for STDERR, creating an unregistered one if necessary
Get a target for STDERR, creating an unregistered one if necessary
Implements
|
#
|
public
|
getTtyTarget(): StreamTargetInterface
Get a TTY target, creating an unregistered one if necessary
Get a TTY target, creating an unregistered one if necessary
Returns a target for STDERR if neither or both of STDOUT and STDERR
refer to an interactive terminal.
Implements
|
#
|
public
|
escape(string $string, bool $escapeNewlines = false): string
Escape inline formatting tags in a string so it can be safely used in a
console message
Escape inline formatting tags in a string so it can be safely used in a
console message
Implements
|
#
|
public
|
removeEscapes(string $string): string
Remove escapes from inline formatting tags in a string
Remove escapes from inline formatting tags in a string
Implements
|
#
|
public
|
removeTags(string $string): string
Remove inline formatting tags from a string
Remove inline formatting tags from a string
Implements
|
#
|
public
|
error(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, bool $count = true)
Print "! $msg1 $msg2" or similar with level LEVEL_ERROR
Print "! $msg1 $msg2" or similar with level LEVEL_ERROR
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
Implements
|
#
|
public
|
errorOnce(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, bool $count = true)
Print "! $msg1 $msg2" or similar with level LEVEL_ERROR once per run
Print "! $msg1 $msg2" or similar with level LEVEL_ERROR once per run
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
Implements
|
#
|
public
|
warn(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, bool $count = true)
Print "^ $msg1 $msg2" or similar with level LEVEL_WARNING
Print "^ $msg1 $msg2" or similar with level LEVEL_WARNING
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
Implements
|
#
|
public
|
warnOnce(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, bool $count = true)
Print "^ $msg1 $msg2" or similar with level LEVEL_WARNING once per run
Print "^ $msg1 $msg2" or similar with level LEVEL_WARNING once per run
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
Implements
|
#
|
public
|
group(string $msg1, ?string $msg2 = null, ?string $endMsg1 = null, ?string $endMsg2 = null)
Increase message indentation level and print "» $msg1 $msg2" or similar
with level LEVEL_NOTICE
Increase message indentation level and print "» $msg1 $msg2" or similar
with level LEVEL_NOTICE
If $endMsg1 or $endMsg2 are not null , "« $endMsg1 $endMsg2" or
similar is printed with level LEVEL_NOTICE when {@see groupEnd()} is
called to close the group.
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
$endMsg1 |
May use inline formatting tags.
|
$endMsg2 |
Inline formatting tags have no special
meaning.
|
Implements
|
#
|
public
|
groupEnd()
Close the group of messages most recently opened with group()
Close the group of messages most recently opened with group()
Implements
|
#
|
public
|
info(string $msg1, ?string $msg2 = null)
Print "> $msg1 $msg2" or similar with level LEVEL_NOTICE
Print "> $msg1 $msg2" or similar with level LEVEL_NOTICE
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
Implements
|
#
|
public
|
infoOnce(string $msg1, ?string $msg2 = null)
Print "> $msg1 $msg2" or similar with level LEVEL_NOTICE once per run
Print "> $msg1 $msg2" or similar with level LEVEL_NOTICE once per run
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
Implements
|
#
|
public
|
log(string $msg1, ?string $msg2 = null)
Print "- $msg1 $msg2" or similar with level LEVEL_INFO
Print "- $msg1 $msg2" or similar with level LEVEL_INFO
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
Implements
|
#
|
public
|
logOnce(string $msg1, ?string $msg2 = null)
Print "- $msg1 $msg2" or similar with level LEVEL_INFO once per run
Print "- $msg1 $msg2" or similar with level LEVEL_INFO once per run
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
Implements
|
#
|
public
|
logProgress(string $msg1, ?string $msg2 = null)
Print "⠋ $msg1 $msg2" or similar with level LEVEL_INFO to TTY targets
without moving to the next line
Print "⠋ $msg1 $msg2" or similar with level LEVEL_INFO to TTY targets
without moving to the next line
May be called repeatedly to display progress updates without disrupting
other console messages or bloating output logs.
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
Implements
|
#
|
public
|
clearProgress()
Clear the message most recently printed with logProgress()
Clear the message most recently printed with logProgress()
Implements
|
#
|
public
|
debug(string $msg1, ?string $msg2 = null, ?Throwable $ex = null, int $depth = 0)
Print ": <caller> $msg1 $msg2" or similar with level LEVEL_DEBUG
Print ": $msg1 $msg2" or similar with level LEVEL_DEBUG
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
$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" or similar with level LEVEL_DEBUG once per
run
Print ": $msg1 $msg2" or similar with level LEVEL_DEBUG once per
run
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
$depth |
To print your caller's name instead of your own, set
$depth to 1.
|
Implements
|
#
|
public
|
message(
string $msg1,
?string $msg2 = null,
int $level = Console::LEVEL_INFO,
int $type = Console::TYPE_UNDECORATED,
?Throwable $ex = null,
bool $count = true,
)
Print "$msg1 $msg2" or similar with level- and type-based formatting
Print "$msg1 $msg2" or similar with level- and type-based formatting
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
Implements
|
#
|
public
|
messageOnce(
string $msg1,
?string $msg2 = null,
int $level = Console::LEVEL_INFO,
int $type = Console::TYPE_UNDECORATED,
?Throwable $ex = null,
bool $count = true,
)
Print "$msg1 $msg2" or similar with level- and type-based formatting once
per run
Print "$msg1 $msg2" or similar with level- and type-based formatting once
per run
Parameters
$msg1 |
May use inline formatting tags (see {@see escape()}).
|
$msg2 |
Inline formatting tags have no special meaning.
|
Implements
|
#
|
public
|
exception(
Throwable $exception,
int $level = Console::LEVEL_ERROR,
?int $traceLevel = Console::LEVEL_DEBUG,
bool $count = true,
)
Print an exception and its stack trace with the given message levels
Print an exception and its stack trace with the given message levels
Parameters
$traceLevel |
If null , the
exception's stack trace is not printed.
|
Implements
|
#
|
public
|
summary(
string $finishedText = 'Command finished',
string $successText = 'without errors',
bool $withResourceUsage = false,
bool $withoutErrorsAndWarnings = false,
bool $withGenericType = 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
Parameters
$finishedText |
May use inline formatting tags (see
{@see escape()}).
|
$successText |
May use inline formatting tags.
|
Implements
|
#
|
public
|
print(string $msg, int $level = Console::LEVEL_INFO)
Print "$msg" to registered targets
Print "$msg" to registered targets
Parameters
$msg |
May use inline formatting tags (see {@see escape()}).
|
Implements
|
#
|
public
|
printStdio(string $msg, int $level = Console::LEVEL_INFO)
Print "$msg" to registered targets that write to STDOUT or STDERR
Print "$msg" to registered targets that write to STDOUT or STDERR
Parameters
$msg |
May use inline formatting tags (see {@see escape()}).
|
Implements
|
#
|
public
|
printTty(string $msg, int $level = Console::LEVEL_INFO)
Print "$msg" to registered targets that write to a TTY
Print "$msg" to registered targets that write to a TTY
Parameters
$msg |
May use inline formatting tags (see {@see escape()}).
|
Implements
|
#
|
public
|
printStdout(string $msg, int $level = Console::LEVEL_INFO)
Print "$msg" to STDOUT, creating an unregistered target if necessary
Print "$msg" to STDOUT, creating an unregistered target if necessary
Parameters
$msg |
May use inline formatting tags (see {@see escape()}).
|
Implements
|
#
|
public
|
count(int $level)
Record a message with the given level without printing anything
Record a message with the given level without printing anything
Implements
|
#
|
public
|
errors(): int
Get the number of error messages recorded so far
Get the number of error messages recorded so far
Implements
|
#
|
public
|
warnings(): int
Get the number of warning messages recorded so far
Get the number of warning messages recorded so far
Implements
|
#
|
protected
|
deregisterStdioTargets(): $this
|
#
|
protected
|
filterTargets(
int-mask-of<self::TARGET_*> $flags,
array<int, TargetInterface>|null $targets = null,
): ($flags is int<1, 31> ? array<int, StreamTargetInterface> : array<int, TargetInterface>)
|
#
|
protected
|
write<T is TargetInterface>(
Console::LEVEL_* $level,
string $msg1,
?string $msg2,
bool $once = false,
?Throwable $ex = null,
bool $count = true,
Console::TYPE_* $type = self::TYPE_STANDARD,
array<Console::LEVEL_*, array<int, T>>|null &$targets = null,
): $this
|
#
|
protected
|
getReturnable(): static
Get an instance that is not running behind a facade
Get an instance that is not running behind a facade
|
#
|