Skip to content

Latest commit

 

History

History
99 lines (79 loc) · 5.14 KB

Console.md

File metadata and controls

99 lines (79 loc) · 5.14 KB

Console

The Console component provides terminal output and message logging via an API similar to console in web browsers.

Default targets

If no targets are registered to receive Console output when a message is written:

  1. Output is appended to a log file in PHP's default temporary directory, created with mode 0600 if it doesn't already exist:

    sys_get_temp_dir() . '/<script_basename>-<realpath_hash>-<user_id>.log'
  2. If the script is running on the command line, output is also written to STDERR.

Debug messages are suppressed unless debug mode is enabled in the environment, e.g. by setting DEBUG=1.

To override these defaults:

Message methods

Method Message level Default prefix
error(), errorOnce() LEVEL_ERROR = 3 !
warn(), warnOnce() LEVEL_WARNING = 4 ^
group(),groupEnd() LEVEL_NOTICE = 5 » , «
info(), infoOnce() LEVEL_NOTICE = 5 >
log(), logOnce() LEVEL_INFO = 6 -
logProgress(), clearProgress() LEVEL_INFO = 6 (spinner, TTY only)
debug(), debugOnce() LEVEL_DEBUG = 7 :

Formatting

The following Markdown-like syntax is supported in Console messages:

Style Tag Typical appearance Example
Heading ___ text ___
*** text ***
## text ##
Bold + primary colour ___NAME___
***NAME***
## NAME (closing delimiter is optional)
"Bold" __ text __
** text **
Bold + default colour __command__
**command**
"Italic" _ text _
* text *
Secondary colour _argument_
*argument*
"Underline" < text > Secondary colour + underline <argument>
Low priority ~~ text ~~ Faint ~~/path/to/script.php:42~~
Inline code ` text ` Bold The input format can be specified using the `-f/--from` option.
Code block ```
text
```
Unchanged
```
$baz = Foo::bar();
```

Paragraphs outside code blocks are wrapped to the width reported by the target, and backslash-escaped punctuation characters and line breaks are preserved.

Escaped line breaks may have a leading space, so the following are equivalent:

Text with a \
hard line break.

Text with a\
hard line break.