SymfonyLogOutputStyler::defaultStyles()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Consolidation\Log;
3
4
use Symfony\Component\Console\Style\SymfonyStyle;
5
use Symfony\Component\Console\Input\StringInput;
6
use Symfony\Component\Console\Output\OutputInterface;
7
8
/**
9
 * Style log messages with Symfony\Component\Console\Style\SymfonyStyle.
10
 * No context variable styling is done.
11
 *
12
 * This is the appropriate styler to use if your desire is to replace
13
 * the use of SymfonyStyle with a Psr-3 logger without changing the
14
 * appearance of your application's output.
15
 */
16
class SymfonyLogOutputStyler implements LogOutputStylerInterface
17
{
18
    public function defaultStyles()
19
    {
20
        return [];
21
    }
22
23
    public function style($context)
24
    {
25
        return $context;
26
    }
27
28
    public function createOutputWrapper(OutputInterface $output)
29
    {
30
        // SymfonyStyle & c. contain both input and output functions,
31
        // but we only need the output methods here. Create a stand-in
32
        // input object to satisfy the SymfonyStyle constructor.
33
        return new SymfonyStyle(new StringInput(''), $output);
34
    }
35
36
    public function log($symfonyStyle, $level, $message, $context)
37
    {
38
        $symfonyStyle->text($message);
39
    }
40
41
    public function success($symfonyStyle, $level, $message, $context)
42
    {
43
        $symfonyStyle->success($message);
44
    }
45
46
    public function error($symfonyStyle, $level, $message, $context)
47
    {
48
        $symfonyStyle->error($message);
49
    }
50
51
    public function warning($symfonyStyle, $level, $message, $context)
52
    {
53
        $symfonyStyle->warning($message);
54
    }
55
56
    public function note($symfonyStyle, $level, $message, $context)
57
    {
58
        $symfonyStyle->note($message);
59
    }
60
61
    public function caution($symfonyStyle, $level, $message, $context)
62
    {
63
        $symfonyStyle->caution($message);
64
    }
65
}
66