1: | <?php declare(strict_types=1); |
2: | |
3: | namespace Salient\Core\Facade; |
4: | |
5: | use Psr\Log\LoggerInterface; |
6: | use Salient\Console\Console as ConsoleService; |
7: | use Salient\Contract\Console\ConsoleFormatterInterface as FormatterInterface; |
8: | use Salient\Contract\Console\ConsoleInterface; |
9: | use Salient\Contract\Console\ConsoleTargetInterface; |
10: | use Salient\Contract\Console\ConsoleTargetStreamInterface; |
11: | use Salient\Contract\Console\ConsoleTargetTypeFlag; |
12: | use Salient\Contract\Console\HasMessageType; |
13: | use Salient\Contract\Console\HasMessageTypes; |
14: | use Salient\Contract\HasMessageLevel; |
15: | use Salient\Contract\HasMessageLevels; |
16: | use Throwable; |
17: | |
18: | /** |
19: | * A facade for the global console service |
20: | * |
21: | * @method static ConsoleInterface clearProgress() Print a "clear to end of line" control sequence with level INFO to TTY targets with a logProgress() message |
22: | * @method static ConsoleInterface count(ConsoleInterface::LEVEL_* $level) Record a message with level $level without printing anything |
23: | * @method static ConsoleInterface debug(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, int $depth = 0) Print ": <caller> $msg1 $msg2" with level DEBUG (see {@see ConsoleInterface::debug()}) |
24: | * @method static ConsoleInterface debugOnce(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, int $depth = 0) Print ": <caller> $msg1 $msg2" with level DEBUG once per run (see {@see ConsoleInterface::debugOnce()}) |
25: | * @method static ConsoleInterface deregisterTarget(ConsoleTargetInterface $target) Deregister and close a registered target (see {@see ConsoleInterface::deregisterTarget()}) |
26: | * @method static ConsoleInterface error(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, bool $count = true) Print "! $msg1 $msg2" with level ERROR |
27: | * @method static ConsoleInterface errorOnce(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, bool $count = true) Print "! $msg1 $msg2" with level ERROR once per run |
28: | * @method static string escape(string $string) Escape a string so it can be safely used in a console message |
29: | * @method static ConsoleInterface exception(Throwable $exception, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_ERROR, ConsoleInterface::LEVEL_*|null $traceLevel = ConsoleInterface::LEVEL_DEBUG) Print an exception's name and message with a given level, optionally followed by its stack trace with a different level (see {@see ConsoleInterface::exception()}) |
30: | * @method static int getErrorCount() Get the number of error messages recorded so far |
31: | * @method static FormatterInterface getFormatter(ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO) Get an output formatter for a registered target (see {@see ConsoleInterface::getFormatter()}) |
32: | * @method static LoggerInterface getLogger() Get a PSR-3 logger |
33: | * @method static ConsoleTargetStreamInterface getStderrTarget() Get a target for STDERR, creating an unregistered one if necessary |
34: | * @method static ConsoleTargetStreamInterface getStdoutTarget() Get a target for STDOUT, creating an unregistered one if necessary |
35: | * @method static ConsoleTargetInterface[] getTargets(ConsoleInterface::LEVEL_*|null $level = null, int-mask-of<ConsoleTargetTypeFlag::*> $flags = 0) Get a list of registered targets, optionally filtered by level and type |
36: | * @method static int getWarningCount() Get the number of warning messages recorded so far |
37: | * @method static int|null getWidth(ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO) Get the width of a registered target in columns (see {@see ConsoleInterface::getWidth()}) |
38: | * @method static ConsoleInterface group(string $msg1, string|null $msg2 = null, string|null $endMsg1 = null, string|null $endMsg2 = null) Increase the indentation level of messages and print "» $msg1 $msg2" with level NOTICE (see {@see ConsoleInterface::group()}) |
39: | * @method static ConsoleInterface groupEnd() Close the nested message group most recently opened with group() |
40: | * @method static ConsoleInterface info(string $msg1, string|null $msg2 = null) Print "➤ $msg1 $msg2" with level NOTICE |
41: | * @method static ConsoleInterface infoOnce(string $msg1, string|null $msg2 = null) Print "➤ $msg1 $msg2" with level NOTICE once per run |
42: | * @method static ConsoleInterface log(string $msg1, string|null $msg2 = null) Print "- $msg1 $msg2" with level INFO |
43: | * @method static ConsoleInterface logOnce(string $msg1, string|null $msg2 = null) Print "- $msg1 $msg2" with level INFO once per run |
44: | * @method static ConsoleInterface logProgress(string $msg1, string|null $msg2 = null) Print "⠿ $msg1 $msg2" with level INFO to TTY targets without moving to the next line (see {@see ConsoleInterface::logProgress()}) |
45: | * @method static ConsoleInterface message(string $msg1, string|null $msg2 = null, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO, ConsoleInterface::TYPE_* $type = ConsoleInterface::TYPE_UNDECORATED, Throwable|null $ex = null, bool $count = true) Print "$msg1 $msg2" with prefix and formatting optionally based on $level |
46: | * @method static ConsoleInterface messageOnce(string $msg1, string|null $msg2 = null, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO, ConsoleInterface::TYPE_* $type = ConsoleInterface::TYPE_UNDECORATED, Throwable|null $ex = null, bool $count = true) Print "$msg1 $msg2" with prefix and formatting optionally based on $level once per run |
47: | * @method static ConsoleInterface print(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO, ConsoleInterface::TYPE_* $type = ConsoleInterface::TYPE_UNFORMATTED) Print "$msg" to registered targets |
48: | * @method static ConsoleInterface printOut(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO, ConsoleInterface::TYPE_* $type = ConsoleInterface::TYPE_UNFORMATTED) Print "$msg" to registered STDOUT or STDERR targets |
49: | * @method static ConsoleInterface printStderr(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO, ConsoleInterface::TYPE_* $type = ConsoleInterface::TYPE_UNFORMATTED) Print "$msg" to STDERR even if no STDERR target is registered |
50: | * @method static ConsoleInterface printStdout(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO, ConsoleInterface::TYPE_* $type = ConsoleInterface::TYPE_UNFORMATTED) Print "$msg" to STDOUT even if no STDOUT target is registered |
51: | * @method static ConsoleInterface printTty(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO, ConsoleInterface::TYPE_* $type = ConsoleInterface::TYPE_UNFORMATTED) Print "$msg" to registered TTY targets |
52: | * @method static ConsoleInterface registerStderrTarget() Register STDERR to receive console output if running on the command line (see {@see ConsoleInterface::registerStderrTarget()}) |
53: | * @method static ConsoleInterface registerStdioTargets() Register STDOUT and STDERR to receive console output if running on the command line (see {@see ConsoleInterface::registerStdioTargets()}) |
54: | * @method static ConsoleInterface registerTarget(ConsoleTargetInterface $target, array<ConsoleInterface::LEVEL_*> $levels = ConsoleInterface::LEVELS_ALL) Register a target to receive console output |
55: | * @method static ConsoleInterface setTargetPrefix(string|null $prefix, int-mask-of<ConsoleTargetTypeFlag::*> $flags = 0) Set or unset the prefix applied to each line of output by any registered targets that implement ConsoleTargetPrefixInterface |
56: | * @method static ConsoleInterface 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 |
57: | * @method static ConsoleInterface warn(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, bool $count = true) Print "^ $msg1 $msg2" with level WARNING |
58: | * @method static ConsoleInterface warnOnce(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, bool $count = true) Print "^ $msg1 $msg2" with level WARNING once per run |
59: | * |
60: | * @api |
61: | * |
62: | * @extends Facade<ConsoleInterface> |
63: | * |
64: | * @generated |
65: | */ |
66: | final class Console extends Facade implements HasMessageLevel, HasMessageLevels, HasMessageType, HasMessageTypes |
67: | { |
68: | /** |
69: | * @internal |
70: | */ |
71: | protected static function getService() |
72: | { |
73: | return [ |
74: | ConsoleInterface::class, |
75: | ConsoleService::class, |
76: | ]; |
77: | } |
78: | } |
79: |