1: <?php declare(strict_types=1);
2:
3: namespace Salient\Core\Facade;
4:
5: use Psr\Log\LoggerInterface;
6: use Salient\Console\ConsoleWriter;
7: use Salient\Contract\Console\ConsoleFormatterInterface as FormatterInterface;
8: use Salient\Contract\Console\ConsoleMessageType as MessageType;
9: use Salient\Contract\Console\ConsoleTargetInterface;
10: use Salient\Contract\Console\ConsoleTargetStreamInterface;
11: use Salient\Contract\Console\ConsoleTargetTypeFlag;
12: use Salient\Contract\Console\ConsoleWriterInterface;
13: use Salient\Contract\Core\MessageLevel as Level;
14: use Salient\Contract\Core\MessageLevelGroup as LevelGroup;
15: use Salient\Core\AbstractFacade;
16: use Throwable;
17:
18: /**
19: * A facade for the global console writer
20: *
21: * @method static ConsoleWriterInterface clearProgress() Print a "clear to end of line" control sequence with level INFO to TTY targets with a logProgress() message
22: * @method static ConsoleWriterInterface count(Level::* $level) Record a message with level $level without printing anything
23: * @method static ConsoleWriterInterface debug(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, int $depth = 0) Print ": <caller> $msg1 $msg2" with level DEBUG (see {@see ConsoleWriterInterface::debug()})
24: * @method static ConsoleWriterInterface 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 ConsoleWriterInterface::debugOnce()})
25: * @method static ConsoleWriterInterface deregisterTarget(ConsoleTargetInterface $target) Deregister and close a registered target (see {@see ConsoleWriterInterface::deregisterTarget()})
26: * @method static ConsoleWriterInterface error(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, bool $count = true) Print "! $msg1 $msg2" with level ERROR
27: * @method static ConsoleWriterInterface 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 ConsoleWriterInterface exception(Throwable $exception, Level::* $level = Level::ERROR, Level::*|null $traceLevel = 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 ConsoleWriterInterface::exception()})
30: * @method static int getErrorCount() Get the number of error messages recorded by the writer so far
31: * @method static FormatterInterface getFormatter(Level::* $level = Level::INFO) Get an output formatter for a registered target (see {@see ConsoleWriterInterface::getFormatter()})
32: * @method static LoggerInterface getLogger() Get a PSR-3 logger backed by the writer
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(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 by the writer so far
37: * @method static int|null getWidth(Level::* $level = Level::INFO) Get the width of a registered target in columns (see {@see ConsoleWriterInterface::getWidth()})
38: * @method static ConsoleWriterInterface 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 ConsoleWriterInterface::group()})
39: * @method static ConsoleWriterInterface groupEnd() Close the nested message group most recently opened with group()
40: * @method static ConsoleWriterInterface info(string $msg1, string|null $msg2 = null) Print "➤ $msg1 $msg2" with level NOTICE
41: * @method static ConsoleWriterInterface infoOnce(string $msg1, string|null $msg2 = null) Print "➤ $msg1 $msg2" with level NOTICE once per run
42: * @method static ConsoleWriterInterface log(string $msg1, string|null $msg2 = null) Print "- $msg1 $msg2" with level INFO
43: * @method static ConsoleWriterInterface logOnce(string $msg1, string|null $msg2 = null) Print "- $msg1 $msg2" with level INFO once per run
44: * @method static ConsoleWriterInterface logProgress(string $msg1, string|null $msg2 = null) Print "⠿ $msg1 $msg2" with level INFO to TTY targets without moving to the next line (see {@see ConsoleWriterInterface::logProgress()})
45: * @method static ConsoleWriterInterface message(string $msg1, string|null $msg2 = null, Level::* $level = Level::INFO, MessageType::* $type = MessageType::UNDECORATED, Throwable|null $ex = null, bool $count = true) Print "$msg1 $msg2" with prefix and formatting optionally based on $level
46: * @method static ConsoleWriterInterface messageOnce(string $msg1, string|null $msg2 = null, Level::* $level = Level::INFO, MessageType::* $type = MessageType::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 ConsoleWriterInterface print(string $msg, Level::* $level = Level::INFO, MessageType::* $type = MessageType::UNFORMATTED) Print "$msg" to registered targets
48: * @method static ConsoleWriterInterface printOut(string $msg, Level::* $level = Level::INFO, MessageType::* $type = MessageType::UNFORMATTED) Print "$msg" to registered STDOUT or STDERR targets
49: * @method static ConsoleWriterInterface printStderr(string $msg, Level::* $level = Level::INFO, MessageType::* $type = MessageType::UNFORMATTED) Print "$msg" to STDERR even if no STDERR target is registered
50: * @method static ConsoleWriterInterface printStdout(string $msg, Level::* $level = Level::INFO, MessageType::* $type = MessageType::UNFORMATTED) Print "$msg" to STDOUT even if no STDOUT target is registered
51: * @method static ConsoleWriterInterface printTty(string $msg, Level::* $level = Level::INFO, MessageType::* $type = MessageType::UNFORMATTED) Print "$msg" to registered TTY targets
52: * @method static ConsoleWriterInterface registerStderrTarget() Register STDERR to receive console output if running on the command line (see {@see ConsoleWriterInterface::registerStderrTarget()})
53: * @method static ConsoleWriterInterface registerStdioTargets() Register STDOUT and STDERR to receive console output if running on the command line (see {@see ConsoleWriterInterface::registerStdioTargets()})
54: * @method static ConsoleWriterInterface registerTarget(ConsoleTargetInterface $target, array<Level::*> $levels = LevelGroup::ALL) Register a target to receive console output
55: * @method static ConsoleWriterInterface 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 ConsoleWriterInterface 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 ConsoleWriterInterface warn(string $msg1, string|null $msg2 = null, Throwable|null $ex = null, bool $count = true) Print "^ $msg1 $msg2" with level WARNING
58: * @method static ConsoleWriterInterface 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 AbstractFacade<ConsoleWriterInterface>
63: *
64: * @generated
65: */
66: final class Console extends AbstractFacade
67: {
68: /**
69: * @internal
70: */
71: protected static function getService()
72: {
73: return [
74: ConsoleWriterInterface::class => ConsoleWriter::class,
75: ];
76: }
77: }
78: