Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / consolidation / log / src / UnstyledLogOutputStyler.php
1 <?php
2 namespace Consolidation\Log;
3
4 use Symfony\Component\Console\Output\OutputInterface;
5 use Symfony\Component\Console\Style\OutputStyle;
6
7 /**
8  * Base class that provides basic unstyled output.
9  */
10 class UnstyledLogOutputStyler implements LogOutputStylerInterface
11 {
12     public function createOutputWrapper(OutputInterface $output)
13     {
14         return $output;
15     }
16
17     /**
18      * {@inheritdoc}
19      */
20     public function defaultStyles()
21     {
22         return [];
23     }
24
25     /**
26      * {@inheritdoc}
27      */
28     public function style($context)
29     {
30         return $context;
31     }
32
33     /**
34      * {@inheritdoc}
35      */
36     protected function write($output, $message, $context)
37     {
38         $output->writeln($message);
39     }
40
41     /**
42      * {@inheritdoc}
43      */
44     public function log($output, $level, $message, $context)
45     {
46         return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
47     }
48
49     /**
50      * {@inheritdoc}
51      */
52     public function success($output, $level, $message, $context)
53     {
54         return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
55     }
56
57     /**
58      * {@inheritdoc}
59      */
60     public function error($output, $level, $message, $context)
61     {
62         return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
63     }
64
65     /**
66      * {@inheritdoc}
67      */
68     public function warning($output, $level, $message, $context)
69     {
70         return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
71     }
72
73     /**
74      * {@inheritdoc}
75      */
76     public function note($output, $level, $message, $context)
77     {
78         return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
79     }
80
81     /**
82      * {@inheritdoc}
83      */
84     public function caution($output, $level, $message, $context)
85     {
86         return $this->write($output, $this->formatMessageByLevel($level, $message, $context), $context);
87     }
88
89     /**
90      * Look up the label and message styles for the specified log level,
91      * and use the log level as the label for the log message.
92      */
93     protected function formatMessageByLevel($level, $message, $context)
94     {
95         return " [$level] $message";
96     }
97 }