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\Target\StreamTargetInterface; |
8: | use Salient\Contract\Console\Target\TargetInterface; |
9: | use Salient\Contract\Console\ConsoleInterface; |
10: | use Salient\Contract\Console\HasMessageType; |
11: | use Salient\Contract\Console\HasMessageTypes; |
12: | use Salient\Contract\Console\HasTargetFlag; |
13: | use Salient\Contract\HasMessageLevel; |
14: | use Salient\Contract\HasMessageLevels; |
15: | use Throwable; |
16: | |
17: | /** |
18: | * A facade for the global console service |
19: | * |
20: | * @method static ConsoleInterface clearProgress() Clear the message most recently printed with logProgress() |
21: | * @method static ConsoleInterface count(ConsoleInterface::LEVEL_* $level) Record a message with the given level without printing anything |
22: | * @method static ConsoleInterface debug(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, int $depth = 0) Print ": <caller> $msg1 $msg2" or similar with level LEVEL_DEBUG (see {@see ConsoleInterface::debug()}) |
23: | * @method static ConsoleInterface debugOnce(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, int $depth = 0) Print ": <caller> $msg1 $msg2" or similar with level LEVEL_DEBUG once per run (see {@see ConsoleInterface::debugOnce()}) |
24: | * @method static ConsoleInterface deregisterTarget(TargetInterface $target) Deregister a target if it is currently registered with the console |
25: | * @method static ConsoleInterface error(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, bool $count = true) Print "! $msg1 $msg2" or similar with level LEVEL_ERROR (see {@see ConsoleInterface::error()}) |
26: | * @method static ConsoleInterface errorOnce(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, bool $count = true) Print "! $msg1 $msg2" or similar with level LEVEL_ERROR once per run (see {@see ConsoleInterface::errorOnce()}) |
27: | * @method static int errors() Get the number of error messages recorded so far |
28: | * @method static string escape(string $string, bool $escapeNewlines = false) Escape inline formatting tags in 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, bool $count = true) Print an exception and its stack trace with the given message levels (see {@see ConsoleInterface::exception()}) |
30: | * @method static StreamTargetInterface getStderrTarget() Get a target for STDERR, creating an unregistered one if necessary |
31: | * @method static StreamTargetInterface getStdoutTarget() Get a target for STDOUT, creating an unregistered one if necessary |
32: | * @method static TargetInterface[] getTargets(ConsoleInterface::LEVEL_*|null $level = null, int-mask-of<ConsoleInterface::TARGET_*> $targetFlags = 0) Get registered targets, optionally filtering them by message level and flag |
33: | * @method static StreamTargetInterface getTtyTarget() Get a TTY target, creating an unregistered one if necessary (see {@see ConsoleInterface::getTtyTarget()}) |
34: | * @method static ConsoleInterface group(string $msg1, string|null $msg2 = null, string|null $endMsg1 = null, string|null $endMsg2 = null) Increase message indentation level and print "» $msg1 $msg2" or similar with level LEVEL_NOTICE (see {@see ConsoleInterface::group()}) |
35: | * @method static ConsoleInterface groupEnd() Close the group of messages most recently opened with group() |
36: | * @method static ConsoleInterface info(string $msg1, string|null $msg2 = null) Print "> $msg1 $msg2" or similar with level LEVEL_NOTICE (see {@see ConsoleInterface::info()}) |
37: | * @method static ConsoleInterface infoOnce(string $msg1, string|null $msg2 = null) Print "> $msg1 $msg2" or similar with level LEVEL_NOTICE once per run (see {@see ConsoleInterface::infoOnce()}) |
38: | * @method static ConsoleInterface log(string $msg1, string|null $msg2 = null) Print "- $msg1 $msg2" or similar with level LEVEL_INFO (see {@see ConsoleInterface::log()}) |
39: | * @method static ConsoleInterface logOnce(string $msg1, string|null $msg2 = null) Print "- $msg1 $msg2" or similar with level LEVEL_INFO once per run (see {@see ConsoleInterface::logOnce()}) |
40: | * @method static ConsoleInterface logProgress(string $msg1, string|null $msg2 = null) Print "⠋ $msg1 $msg2" or similar with level LEVEL_INFO to TTY targets without moving to the next line (see {@see ConsoleInterface::logProgress()}) |
41: | * @method static LoggerInterface logger() Get a PSR-3 logger backed by the console |
42: | * @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" or similar with level- and type-based formatting (see {@see ConsoleInterface::message()}) |
43: | * @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" or similar with level- and type-based formatting once per run (see {@see ConsoleInterface::messageOnce()}) |
44: | * @method static ConsoleInterface print(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO) Print "$msg" to registered targets (see {@see ConsoleInterface::print()}) |
45: | * @method static ConsoleInterface printStdio(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO) Print "$msg" to registered targets that write to STDOUT or STDERR (see {@see ConsoleInterface::printStdio()}) |
46: | * @method static ConsoleInterface printStdout(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO) Print "$msg" to STDOUT, creating an unregistered target if necessary (see {@see ConsoleInterface::printStdout()}) |
47: | * @method static ConsoleInterface printTty(string $msg, ConsoleInterface::LEVEL_* $level = ConsoleInterface::LEVEL_INFO) Print "$msg" to registered targets that write to a TTY (see {@see ConsoleInterface::printTty()}) |
48: | * @method static ConsoleInterface registerStderrTarget(bool|null $debug = null) Register STDERR for console output if running on the command line (see {@see ConsoleInterface::registerStderrTarget()}) |
49: | * @method static ConsoleInterface registerStdioTargets(bool|null $debug = null) Register STDOUT and STDERR for console output if running on the command line (see {@see ConsoleInterface::registerStdioTargets()}) |
50: | * @method static ConsoleInterface registerTarget(TargetInterface $target, array<ConsoleInterface::LEVEL_*> $levels = ConsoleInterface::LEVELS_ALL) Register a target to receive output with each of the given message levels from the console |
51: | * @method static string removeEscapes(string $string) Remove escapes from inline formatting tags in a string |
52: | * @method static string removeTags(string $string) Remove inline formatting tags from a string |
53: | * @method static ConsoleInterface setPrefix(string|null $prefix, int-mask-of<ConsoleInterface::TARGET_*> $targetFlags = 0) Set or unset the prefix applied to each line of output by registered targets that implement HasPrefix after optionally filtering them by flag |
54: | * @method static ConsoleInterface 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 (see {@see ConsoleInterface::summary()}) |
55: | * @method static ConsoleInterface warn(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, bool $count = true) Print "^ $msg1 $msg2" or similar with level LEVEL_WARNING (see {@see ConsoleInterface::warn()}) |
56: | * @method static ConsoleInterface warnOnce(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, bool $count = true) Print "^ $msg1 $msg2" or similar with level LEVEL_WARNING once per run (see {@see ConsoleInterface::warnOnce()}) |
57: | * @method static int warnings() Get the number of warning messages recorded so far |
58: | * |
59: | * @api |
60: | * |
61: | * @extends Facade<ConsoleInterface> |
62: | * |
63: | * @generated |
64: | */ |
65: | final class Console extends Facade implements HasMessageLevel, HasMessageLevels, HasMessageType, HasMessageTypes, HasTargetFlag |
66: | { |
67: | /** |
68: | * @internal |
69: | */ |
70: | protected static function getService() |
71: | { |
72: | return [ |
73: | ConsoleInterface::class, |
74: | ConsoleService::class, |
75: | ]; |
76: | } |
77: | } |
78: |