Methods |
public
|
logger(): LoggerInterface
Get a PSR-3 logger backed by the console
Get a PSR-3 logger backed by the console
Implemented by
|
#
|
public
|
registerTarget(TargetInterface $target, array<ConsoleInterface::LEVEL_*> $levels = ConsoleInterface::LEVELS_ALL): $this
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
Implemented by
|
#
|
public
|
deregisterTarget(TargetInterface $target): $this
Deregister a target if it is currently registered with the console
Deregister a target if it is currently registered with the console
Implemented by
|
#
|
public
|
registerStderrTarget(?bool $debug = null): $this
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
Implemented by
|
#
|
public
|
registerStdioTargets(?bool $debug = null): $this
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
Implemented by
|
#
|
public
|
setPrefix(?string $prefix, int-mask-of<ConsoleInterface::TARGET_*> $targetFlags = 0): $this
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
Implemented by
|
#
|
public
|
getTargets(
ConsoleInterface::LEVEL_*|null $level = null,
int-mask-of<ConsoleInterface::TARGET_*> $targetFlags = 0,
): TargetInterface[]
Get registered targets, optionally filtering them by message level and
flag
Get registered targets, optionally filtering them by message level and
flag
Implemented by
|
#
|
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
Implemented by
|
#
|
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
Implemented by
|
#
|
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.
Implemented by
|
#
|
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
Implemented by
|
#
|
public
|
removeEscapes(string $string): string
Remove escapes from inline formatting tags in a string
Remove escapes from inline formatting tags in a string
Implemented by
|
#
|
public
|
removeTags(string $string): string
Remove inline formatting tags from a string
Remove inline formatting tags from a string
Implemented by
|
#
|
public
|
error(string $msg1, string|null $msg2 = null, ?Throwable $ex = null, bool $count = true): $this
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.
|
Implemented by
|
#
|
public
|
errorOnce(string $msg1, string|null $msg2 = null, ?Throwable $ex = null, bool $count = true): $this
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.
|
Implemented by
|
#
|
public
|
warn(string $msg1, string|null $msg2 = null, ?Throwable $ex = null, bool $count = true): $this
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.
|
Implemented by
|
#
|
public
|
warnOnce(string $msg1, string|null $msg2 = null, ?Throwable $ex = null, bool $count = true): $this
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.
|
Implemented by
|
#
|
public
|
group(string $msg1, string|null $msg2 = null, string|null $endMsg1 = null, string|null $endMsg2 = null): $this
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.
|
Implemented by
|
#
|
public
|
groupEnd(): $this
Close the group of messages most recently opened with group()
Close the group of messages most recently opened with group()
Implemented by
|
#
|
public
|
info(string $msg1, string|null $msg2 = null): $this
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.
|
Implemented by
|
#
|
public
|
infoOnce(string $msg1, string|null $msg2 = null): $this
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.
|
Implemented by
|
#
|
public
|
log(string $msg1, string|null $msg2 = null): $this
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.
|
Implemented by
|
#
|
public
|
logOnce(string $msg1, string|null $msg2 = null): $this
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.
|
Implemented by
|
#
|
public
|
logProgress(string $msg1, string|null $msg2 = null): $this
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.
|
Implemented by
|
#
|
public
|
clearProgress(): $this
Clear the message most recently printed with logProgress()
Clear the message most recently printed with logProgress()
Implemented by
|
#
|
public
|
debug(string $msg1, string|null $msg2 = null, ?Throwable $ex = null, int $depth = 0): $this
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.
|
Implemented by
|
#
|
public
|
debugOnce(string $msg1, string|null $msg2 = null, ?Throwable $ex = null, int $depth = 0): $this
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.
|
Implemented by
|
#
|
public
|
message(
string $msg1,
string|null $msg2 = null,
ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO,
ConsoleInterface::TYPE_* $type = ConsoleInterface::TYPE_UNDECORATED,
?Throwable $ex = null,
bool $count = true,
): $this
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.
|
Implemented by
|
#
|
public
|
messageOnce(
string $msg1,
string|null $msg2 = null,
ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO,
ConsoleInterface::TYPE_* $type = ConsoleInterface::TYPE_UNDECORATED,
?Throwable $ex = null,
bool $count = true,
): $this
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.
|
Implemented by
|
#
|
public
|
exception(
Throwable $exception,
ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_ERROR,
ConsoleInterface::LEVEL_*|null $traceLevel = ConsoleInterface::LEVEL_DEBUG,
bool $count = true,
): $this
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.
|
Implemented by
|
#
|
public
|
summary(
string $finishedText = 'Command finished',
string $successText = 'without errors',
bool $withResourceUsage = false,
bool $withoutErrorsAndWarnings = false,
bool $withGenericType = 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
Parameters
$finishedText |
May use inline formatting tags (see
{@see escape()}).
|
$successText |
May use inline formatting tags.
|
Implemented by
|
#
|
public
|
print(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO): $this
Print "$msg" to registered targets
Print "$msg" to registered targets
Parameters
$msg |
May use inline formatting tags (see {@see escape()}).
|
Implemented by
|
#
|
public
|
printStdio(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO): $this
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()}).
|
Implemented by
|
#
|
public
|
printTty(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO): $this
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()}).
|
Implemented by
|
#
|
public
|
printStdout(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO): $this
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()}).
|
Implemented by
|
#
|
public
|
count(ConsoleInterface::LEVEL_* $level): $this
Record a message with the given level without printing anything
Record a message with the given level without printing anything
Implemented by
|
#
|
public
|
errors(): int
Get the number of error messages recorded so far
Get the number of error messages recorded so far
Implemented by
|
#
|
public
|
warnings(): int
Get the number of warning messages recorded so far
Get the number of warning messages recorded so far
Implemented by
|
#
|