Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / consolidation / log / src / LogOutputStylerInterface.php
1 <?php
2 namespace Consolidation\Log;
3
4 use Symfony\Component\Console\Output\OutputInterface;
5
6 /**
7  * Allow a log message to by styled.
8  *
9  * Styling happens in two phases:
10  *
11  * 1. Prior to message interpolation, context variables are styled
12  *    via the 'style()' method, using styles provided in the context
13  *    under the '_style' key, and also using styles provided by the
14  *    'defaultStyles()' method.
15  *
16  * @see Symfony\Component\Console\Logger\ConsoleLogger::interpolate()
17  *
18  * 2. After message interpolation, an appropriate method based on the
19  *    log level will be called. StyledConsoleLogger::$formatFunctionMap
20  *    is used to map the LogLevel to a LogOutputStylerInterface method to call.
21  *
22  * It is possible to select the exact class to use as the log styler
23  * in the constructor of StyledConsoleLogger, and the mapping from
24  * LogLevel to format function can also be extended. It is possible to
25  * add new format methods not defined here, if desired, so long as
26  * any method named in the format function map is implemented by the
27  * selected log styler class.
28  */
29 interface LogOutputStylerInterface
30 {
31     const STYLE_CONTEXT_KEY = '_style';
32
33     /**
34      * Return an array of default styles to use in an application.
35      * The key of the style is the variable name that the style
36      * should be applied to (or '*' to match all variables that have
37      * no specific style set), and the value is the contents of the
38      * Symfony style tag to wrap around the variable value.
39      *
40      * Example:
41      *  message:        'Running {command}'
42      *  context:        ['command' => 'pwd']
43      *  default styles: ['*' => 'info']
44      *  result:         'Running <info>pwd</>'
45      */
46     public function defaultStyles();
47
48     /**
49      * Apply styles specified in the STYLE_CONTEXT_KEY context variable to
50      * the other named variables stored in the context. The styles from
51      * the context are unioned with the default styles.
52      */
53     public function style($context);
54
55     /**
56      * Create a wrapper object for the output stream. If this styler
57      * does not require an output wrapper, it should just return
58      * its $output parameter.
59      */
60     public function createOutputWrapper(OutputInterface $output);
61
62     /**
63      * Print an ordinary log message, usually unstyled.
64      */
65     public function log($output, $level, $message, $context);
66
67     /**
68      * Print a success message.
69      */
70     public function success($output, $level, $message, $context);
71
72     /**
73      * Print an error message. Used when log level is:
74      *  - LogLevel::EMERGENCY
75      *  - LogLevel::ALERT
76      *  - LogLevel::CRITICAL
77      *  - LogLevel::ERROR
78      */
79     public function error($output, $level, $message, $context);
80
81     /**
82      * Print a warning message. Used when log level is:
83      *   - LogLevel::WARNING
84      */
85     public function warning($output, $level, $message, $context);
86
87     /**
88      * Print a note. Similar to 'text', but may contain additional
89      * styling (e.g. the task name). Used when log level is:
90      *   - LogLevel::NOTICE
91      *   - LogLevel::INFO
92      *   - LogLevel::DEBUG
93      *
94      * IMPORTANT: Symfony loggers only display LogLevel::NOTICE when the
95      * the verbosity level is  VERBOSITY_VERBOSE, unless overridden in the
96      * constructor. Robo\Common\Logger emits LogLevel::NOTICE at
97      * VERBOSITY_NORMAL so that these messages will always be displayed.
98      */
99     public function note($output, $level, $message, $context);
100
101     /**
102      * Print an error message. Not used by default by StyledConsoleLogger.
103      */
104     public function caution($output, $level, $message, $context);
105 }