@@ -12,5 +12,5 @@ |
||
12 | 12 | */ |
13 | 13 | interface FormatterInterface |
14 | 14 | { |
15 | - public function format(Record $record); |
|
15 | + public function format(Record $record); |
|
16 | 16 | } |
@@ -10,7 +10,6 @@ |
||
10 | 10 | * @package Yep\WorkflowLogger\Formatter |
11 | 11 | * @author Martin Zeman (Zemistr) <[email protected]> |
12 | 12 | */ |
13 | -interface FormatterInterface |
|
14 | -{ |
|
13 | +interface FormatterInterface { |
|
15 | 14 | public function format(Record $record); |
16 | 15 | } |
@@ -13,45 +13,45 @@ |
||
13 | 13 | */ |
14 | 14 | class StandardFormatter implements FormatterInterface |
15 | 15 | { |
16 | - const FORMAT = "[%datetime%] %level%: %message%\n%contextPlaceholder%"; |
|
17 | - const CONTEXT_FORMAT = "Context:\n%context%\n"; |
|
18 | - const DATETIME_FORMAT = 'Y-m-d H:i:s.u'; |
|
19 | - |
|
20 | - /** |
|
21 | - * @var DumperInterface |
|
22 | - */ |
|
23 | - protected $dumper; |
|
24 | - |
|
25 | - public function __construct(DumperInterface $dumper) |
|
26 | - { |
|
27 | - $this->dumper = $dumper; |
|
28 | - } |
|
29 | - |
|
30 | - public function format(Record $record) |
|
31 | - { |
|
32 | - $contextString = ''; |
|
33 | - |
|
34 | - if ($context = $record->getContext()) { |
|
35 | - $contextString = strtr( |
|
36 | - self::CONTEXT_FORMAT, |
|
37 | - [ |
|
38 | - '%context%' => $this->dumper->dump($context), |
|
39 | - ] |
|
40 | - ); |
|
41 | - } |
|
42 | - |
|
43 | - $string = strtr( |
|
44 | - self::FORMAT, |
|
45 | - [ |
|
46 | - '%datetime%' => $record->getDatetime()->format( |
|
47 | - static::DATETIME_FORMAT |
|
48 | - ), |
|
49 | - '%level%' => $record->getLevel(), |
|
50 | - '%message%' => $record->getMessage(), |
|
51 | - '%contextPlaceholder%' => $contextString, |
|
52 | - ] |
|
53 | - ); |
|
54 | - |
|
55 | - return $string; |
|
56 | - } |
|
16 | + const FORMAT = "[%datetime%] %level%: %message%\n%contextPlaceholder%"; |
|
17 | + const CONTEXT_FORMAT = "Context:\n%context%\n"; |
|
18 | + const DATETIME_FORMAT = 'Y-m-d H:i:s.u'; |
|
19 | + |
|
20 | + /** |
|
21 | + * @var DumperInterface |
|
22 | + */ |
|
23 | + protected $dumper; |
|
24 | + |
|
25 | + public function __construct(DumperInterface $dumper) |
|
26 | + { |
|
27 | + $this->dumper = $dumper; |
|
28 | + } |
|
29 | + |
|
30 | + public function format(Record $record) |
|
31 | + { |
|
32 | + $contextString = ''; |
|
33 | + |
|
34 | + if ($context = $record->getContext()) { |
|
35 | + $contextString = strtr( |
|
36 | + self::CONTEXT_FORMAT, |
|
37 | + [ |
|
38 | + '%context%' => $this->dumper->dump($context), |
|
39 | + ] |
|
40 | + ); |
|
41 | + } |
|
42 | + |
|
43 | + $string = strtr( |
|
44 | + self::FORMAT, |
|
45 | + [ |
|
46 | + '%datetime%' => $record->getDatetime()->format( |
|
47 | + static::DATETIME_FORMAT |
|
48 | + ), |
|
49 | + '%level%' => $record->getLevel(), |
|
50 | + '%message%' => $record->getMessage(), |
|
51 | + '%contextPlaceholder%' => $contextString, |
|
52 | + ] |
|
53 | + ); |
|
54 | + |
|
55 | + return $string; |
|
56 | + } |
|
57 | 57 | } |
@@ -11,8 +11,7 @@ discard block |
||
11 | 11 | * @package Yep\WorkflowLogger\Formatter |
12 | 12 | * @author Martin Zeman (Zemistr) <[email protected]> |
13 | 13 | */ |
14 | -class StandardFormatter implements FormatterInterface |
|
15 | -{ |
|
14 | +class StandardFormatter implements FormatterInterface { |
|
16 | 15 | const FORMAT = "[%datetime%] %level%: %message%\n%contextPlaceholder%"; |
17 | 16 | const CONTEXT_FORMAT = "Context:\n%context%\n"; |
18 | 17 | const DATETIME_FORMAT = 'Y-m-d H:i:s.u'; |
@@ -22,13 +21,11 @@ discard block |
||
22 | 21 | */ |
23 | 22 | protected $dumper; |
24 | 23 | |
25 | - public function __construct(DumperInterface $dumper) |
|
26 | - { |
|
24 | + public function __construct(DumperInterface $dumper) { |
|
27 | 25 | $this->dumper = $dumper; |
28 | 26 | } |
29 | 27 | |
30 | - public function format(Record $record) |
|
31 | - { |
|
28 | + public function format(Record $record) { |
|
32 | 29 | $contextString = ''; |
33 | 30 | |
34 | 31 | if ($context = $record->getContext()) { |
@@ -10,9 +10,9 @@ |
||
10 | 10 | */ |
11 | 11 | interface LoggerInterface extends \Psr\Log\LoggerInterface |
12 | 12 | { |
13 | - /** |
|
14 | - * @param string $name |
|
15 | - * @return Workflow |
|
16 | - */ |
|
17 | - public function workflow($name); |
|
13 | + /** |
|
14 | + * @param string $name |
|
15 | + * @return Workflow |
|
16 | + */ |
|
17 | + public function workflow($name); |
|
18 | 18 | } |
@@ -8,8 +8,7 @@ |
||
8 | 8 | * @package Yep\WorkflowLogger |
9 | 9 | * @author Martin Zeman (Zemistr) <[email protected]> |
10 | 10 | */ |
11 | -interface LoggerInterface extends \Psr\Log\LoggerInterface |
|
12 | -{ |
|
11 | +interface LoggerInterface extends \Psr\Log\LoggerInterface { |
|
13 | 12 | /** |
14 | 13 | * @param string $name |
15 | 14 | * @return Workflow |
@@ -10,75 +10,75 @@ |
||
10 | 10 | */ |
11 | 11 | class Record |
12 | 12 | { |
13 | - /** |
|
14 | - * @var array |
|
15 | - */ |
|
16 | - protected $context; |
|
13 | + /** |
|
14 | + * @var array |
|
15 | + */ |
|
16 | + protected $context; |
|
17 | 17 | |
18 | - /** |
|
19 | - * @var \DateTime |
|
20 | - */ |
|
21 | - protected $datetime; |
|
18 | + /** |
|
19 | + * @var \DateTime |
|
20 | + */ |
|
21 | + protected $datetime; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - protected $level; |
|
23 | + /** |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + protected $level; |
|
27 | 27 | |
28 | - /** |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - protected $message; |
|
28 | + /** |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + protected $message; |
|
32 | 32 | |
33 | - /** |
|
34 | - * Record constructor. |
|
35 | - * |
|
36 | - * @param \DateTime $datetime |
|
37 | - * @param string $message |
|
38 | - * @param string $level |
|
39 | - * @param array $context |
|
40 | - */ |
|
41 | - public function __construct( |
|
42 | - \DateTime $datetime, |
|
43 | - $message, |
|
44 | - $level, |
|
45 | - array $context |
|
46 | - ) { |
|
47 | - $this->datetime = $datetime; |
|
48 | - $this->message = (string)$message; |
|
49 | - $this->level = (string)$level; |
|
50 | - $this->context = $context; |
|
51 | - } |
|
33 | + /** |
|
34 | + * Record constructor. |
|
35 | + * |
|
36 | + * @param \DateTime $datetime |
|
37 | + * @param string $message |
|
38 | + * @param string $level |
|
39 | + * @param array $context |
|
40 | + */ |
|
41 | + public function __construct( |
|
42 | + \DateTime $datetime, |
|
43 | + $message, |
|
44 | + $level, |
|
45 | + array $context |
|
46 | + ) { |
|
47 | + $this->datetime = $datetime; |
|
48 | + $this->message = (string)$message; |
|
49 | + $this->level = (string)$level; |
|
50 | + $this->context = $context; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return \DateTime |
|
55 | - */ |
|
56 | - public function getDatetime() |
|
57 | - { |
|
58 | - return $this->datetime; |
|
59 | - } |
|
53 | + /** |
|
54 | + * @return \DateTime |
|
55 | + */ |
|
56 | + public function getDatetime() |
|
57 | + { |
|
58 | + return $this->datetime; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - public function getMessage() |
|
65 | - { |
|
66 | - return $this->message; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + public function getMessage() |
|
65 | + { |
|
66 | + return $this->message; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function getLevel() |
|
73 | - { |
|
74 | - return $this->level; |
|
75 | - } |
|
69 | + /** |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function getLevel() |
|
73 | + { |
|
74 | + return $this->level; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - public function getContext() |
|
81 | - { |
|
82 | - return $this->context; |
|
83 | - } |
|
77 | + /** |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + public function getContext() |
|
81 | + { |
|
82 | + return $this->context; |
|
83 | + } |
|
84 | 84 | } |
@@ -8,8 +8,7 @@ discard block |
||
8 | 8 | * @package Yep\WorkflowLogger |
9 | 9 | * @author Martin Zeman (Zemistr) <[email protected]> |
10 | 10 | */ |
11 | -class Record |
|
12 | -{ |
|
11 | +class Record { |
|
13 | 12 | /** |
14 | 13 | * @var array |
15 | 14 | */ |
@@ -53,32 +52,28 @@ discard block |
||
53 | 52 | /** |
54 | 53 | * @return \DateTime |
55 | 54 | */ |
56 | - public function getDatetime() |
|
57 | - { |
|
55 | + public function getDatetime() { |
|
58 | 56 | return $this->datetime; |
59 | 57 | } |
60 | 58 | |
61 | 59 | /** |
62 | 60 | * @return string |
63 | 61 | */ |
64 | - public function getMessage() |
|
65 | - { |
|
62 | + public function getMessage() { |
|
66 | 63 | return $this->message; |
67 | 64 | } |
68 | 65 | |
69 | 66 | /** |
70 | 67 | * @return string |
71 | 68 | */ |
72 | - public function getLevel() |
|
73 | - { |
|
69 | + public function getLevel() { |
|
74 | 70 | return $this->level; |
75 | 71 | } |
76 | 72 | |
77 | 73 | /** |
78 | 74 | * @return array |
79 | 75 | */ |
80 | - public function getContext() |
|
81 | - { |
|
76 | + public function getContext() { |
|
82 | 77 | return $this->context; |
83 | 78 | } |
84 | 79 | } |
@@ -10,5 +10,5 @@ |
||
10 | 10 | */ |
11 | 11 | interface DumperInterface |
12 | 12 | { |
13 | - public function dump(array $context); |
|
13 | + public function dump(array $context); |
|
14 | 14 | } |
@@ -8,7 +8,6 @@ |
||
8 | 8 | * @package Yep\WorkflowLogger\ContextDumper |
9 | 9 | * @author Martin Zeman (Zemistr) <[email protected]> |
10 | 10 | */ |
11 | -interface DumperInterface |
|
12 | -{ |
|
11 | +interface DumperInterface { |
|
13 | 12 | public function dump(array $context); |
14 | 13 | } |
@@ -13,24 +13,24 @@ |
||
13 | 13 | */ |
14 | 14 | class SymfonyVarDumper implements DumperInterface |
15 | 15 | { |
16 | - /** |
|
17 | - * @var VarCloner |
|
18 | - */ |
|
19 | - protected $cloner; |
|
16 | + /** |
|
17 | + * @var VarCloner |
|
18 | + */ |
|
19 | + protected $cloner; |
|
20 | 20 | |
21 | - /** |
|
22 | - * @var CliDumper |
|
23 | - */ |
|
24 | - protected $dumper; |
|
21 | + /** |
|
22 | + * @var CliDumper |
|
23 | + */ |
|
24 | + protected $dumper; |
|
25 | 25 | |
26 | - public function __construct($flags = CliDumper::DUMP_LIGHT_ARRAY) |
|
27 | - { |
|
28 | - $this->cloner = new VarCloner(); |
|
29 | - $this->dumper = new CliDumper(null, null, $flags); |
|
30 | - } |
|
26 | + public function __construct($flags = CliDumper::DUMP_LIGHT_ARRAY) |
|
27 | + { |
|
28 | + $this->cloner = new VarCloner(); |
|
29 | + $this->dumper = new CliDumper(null, null, $flags); |
|
30 | + } |
|
31 | 31 | |
32 | - public function dump(array $context) |
|
33 | - { |
|
34 | - return $this->dumper->dump($this->cloner->cloneVar($context), true); |
|
35 | - } |
|
32 | + public function dump(array $context) |
|
33 | + { |
|
34 | + return $this->dumper->dump($this->cloner->cloneVar($context), true); |
|
35 | + } |
|
36 | 36 | } |
@@ -11,8 +11,7 @@ discard block |
||
11 | 11 | * @package Yep\WorkflowLogger\ContextDumper |
12 | 12 | * @author Martin Zeman (Zemistr) <[email protected]> |
13 | 13 | */ |
14 | -class SymfonyVarDumper implements DumperInterface |
|
15 | -{ |
|
14 | +class SymfonyVarDumper implements DumperInterface { |
|
16 | 15 | /** |
17 | 16 | * @var VarCloner |
18 | 17 | */ |
@@ -23,14 +22,12 @@ discard block |
||
23 | 22 | */ |
24 | 23 | protected $dumper; |
25 | 24 | |
26 | - public function __construct($flags = CliDumper::DUMP_LIGHT_ARRAY) |
|
27 | - { |
|
25 | + public function __construct($flags = CliDumper::DUMP_LIGHT_ARRAY) { |
|
28 | 26 | $this->cloner = new VarCloner(); |
29 | 27 | $this->dumper = new CliDumper(null, null, $flags); |
30 | 28 | } |
31 | 29 | |
32 | - public function dump(array $context) |
|
33 | - { |
|
30 | + public function dump(array $context) { |
|
34 | 31 | return $this->dumper->dump($this->cloner->cloneVar($context), true); |
35 | 32 | } |
36 | 33 | } |
@@ -10,8 +10,8 @@ |
||
10 | 10 | */ |
11 | 11 | class PrintRDumper implements DumperInterface |
12 | 12 | { |
13 | - public function dump(array $context) |
|
14 | - { |
|
15 | - return print_r($context, true); |
|
16 | - } |
|
13 | + public function dump(array $context) |
|
14 | + { |
|
15 | + return print_r($context, true); |
|
16 | + } |
|
17 | 17 | } |
@@ -8,10 +8,8 @@ |
||
8 | 8 | * @package Yep\WorkflowLogger\ContextDumper |
9 | 9 | * @author Martin Zeman (Zemistr) <[email protected]> |
10 | 10 | */ |
11 | -class PrintRDumper implements DumperInterface |
|
12 | -{ |
|
13 | - public function dump(array $context) |
|
14 | - { |
|
11 | +class PrintRDumper implements DumperInterface { |
|
12 | + public function dump(array $context) { |
|
15 | 13 | return print_r($context, true); |
16 | 14 | } |
17 | 15 | } |
@@ -12,19 +12,19 @@ |
||
12 | 12 | */ |
13 | 13 | class TracyDumper implements DumperInterface |
14 | 14 | { |
15 | - /** |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - protected $options; |
|
15 | + /** |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + protected $options; |
|
19 | 19 | |
20 | - public function __construct( |
|
21 | - array $options = [Dumper::DEPTH => 8, Dumper::TRUNCATE => 512] |
|
22 | - ) { |
|
23 | - $this->options = $options; |
|
24 | - } |
|
20 | + public function __construct( |
|
21 | + array $options = [Dumper::DEPTH => 8, Dumper::TRUNCATE => 512] |
|
22 | + ) { |
|
23 | + $this->options = $options; |
|
24 | + } |
|
25 | 25 | |
26 | - public function dump(array $context) |
|
27 | - { |
|
28 | - return Dumper::toText($context, $this->options); |
|
29 | - } |
|
26 | + public function dump(array $context) |
|
27 | + { |
|
28 | + return Dumper::toText($context, $this->options); |
|
29 | + } |
|
30 | 30 | } |
@@ -10,8 +10,7 @@ discard block |
||
10 | 10 | * @package Yep\WorkflowLogger\ContextDumper |
11 | 11 | * @author Martin Zeman (Zemistr) <[email protected]> |
12 | 12 | */ |
13 | -class TracyDumper implements DumperInterface |
|
14 | -{ |
|
13 | +class TracyDumper implements DumperInterface { |
|
15 | 14 | /** |
16 | 15 | * @var array |
17 | 16 | */ |
@@ -23,8 +22,7 @@ discard block |
||
23 | 22 | $this->options = $options; |
24 | 23 | } |
25 | 24 | |
26 | - public function dump(array $context) |
|
27 | - { |
|
25 | + public function dump(array $context) { |
|
28 | 26 | return Dumper::toText($context, $this->options); |
29 | 27 | } |
30 | 28 | } |
@@ -14,277 +14,277 @@ |
||
14 | 14 | */ |
15 | 15 | class Workflow implements LoggerInterface |
16 | 16 | { |
17 | - const EMERGENCY = 'emergency'; |
|
18 | - const ALERT = 'alert'; |
|
19 | - const CRITICAL = 'critical'; |
|
20 | - const ERROR = 'error'; |
|
21 | - const WARNING = 'warning'; |
|
22 | - const NOTICE = 'notice'; |
|
23 | - const INFO = 'info'; |
|
24 | - const DEBUG = 'debug'; |
|
17 | + const EMERGENCY = 'emergency'; |
|
18 | + const ALERT = 'alert'; |
|
19 | + const CRITICAL = 'critical'; |
|
20 | + const ERROR = 'error'; |
|
21 | + const WARNING = 'warning'; |
|
22 | + const NOTICE = 'notice'; |
|
23 | + const INFO = 'info'; |
|
24 | + const DEBUG = 'debug'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Logging levels from syslog protocol defined in RFC 5424 |
|
28 | - * |
|
29 | - * @var array|string[] $levels Logging levels |
|
30 | - */ |
|
31 | - protected static $levels = [ |
|
32 | - self::DEBUG => 'DEBUG', |
|
33 | - self::INFO => 'INFO', |
|
34 | - self::NOTICE => 'NOTICE', |
|
35 | - self::WARNING => 'WARNING', |
|
36 | - self::ERROR => 'ERROR', |
|
37 | - self::CRITICAL => 'CRITICAL', |
|
38 | - self::ALERT => 'ALERT', |
|
39 | - self::EMERGENCY => 'EMERGENCY', |
|
40 | - ]; |
|
26 | + /** |
|
27 | + * Logging levels from syslog protocol defined in RFC 5424 |
|
28 | + * |
|
29 | + * @var array|string[] $levels Logging levels |
|
30 | + */ |
|
31 | + protected static $levels = [ |
|
32 | + self::DEBUG => 'DEBUG', |
|
33 | + self::INFO => 'INFO', |
|
34 | + self::NOTICE => 'NOTICE', |
|
35 | + self::WARNING => 'WARNING', |
|
36 | + self::ERROR => 'ERROR', |
|
37 | + self::CRITICAL => 'CRITICAL', |
|
38 | + self::ALERT => 'ALERT', |
|
39 | + self::EMERGENCY => 'EMERGENCY', |
|
40 | + ]; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @var int|string |
|
44 | - */ |
|
45 | - private $level; |
|
42 | + /** |
|
43 | + * @var int|string |
|
44 | + */ |
|
45 | + private $level; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @var FormatterInterface |
|
49 | - */ |
|
50 | - protected $formatter; |
|
47 | + /** |
|
48 | + * @var FormatterInterface |
|
49 | + */ |
|
50 | + protected $formatter; |
|
51 | 51 | |
52 | - /** |
|
53 | - * @var Logger |
|
54 | - */ |
|
55 | - protected $logger; |
|
52 | + /** |
|
53 | + * @var Logger |
|
54 | + */ |
|
55 | + protected $logger; |
|
56 | 56 | |
57 | - /** |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - protected $name; |
|
57 | + /** |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + protected $name; |
|
61 | 61 | |
62 | - /** |
|
63 | - * @var array|Record[] |
|
64 | - */ |
|
65 | - protected $records = []; |
|
62 | + /** |
|
63 | + * @var array|Record[] |
|
64 | + */ |
|
65 | + protected $records = []; |
|
66 | 66 | |
67 | - /** |
|
68 | - * @var \DateTimeZone |
|
69 | - */ |
|
70 | - protected $timezone; |
|
67 | + /** |
|
68 | + * @var \DateTimeZone |
|
69 | + */ |
|
70 | + protected $timezone; |
|
71 | 71 | |
72 | - /** |
|
73 | - * Workflow constructor. |
|
74 | - * |
|
75 | - * @param LoggerInterface $logger Main logger |
|
76 | - * @param FormatterInterface $formatter Workflow records formatter |
|
77 | - * @param \DateTimeZone $timezone Current timezone |
|
78 | - * @param string $name Workflow name |
|
79 | - * @param int|string $level Workflow level code |
|
80 | - */ |
|
81 | - public function __construct( |
|
82 | - LoggerInterface $logger, |
|
83 | - FormatterInterface $formatter, |
|
84 | - \DateTimeZone $timezone, |
|
85 | - $name, |
|
86 | - $level |
|
87 | - ) { |
|
88 | - $this->logger = $logger; |
|
89 | - $this->formatter = $formatter; |
|
90 | - $this->timezone = $timezone; |
|
91 | - $this->name = (string)$name; |
|
92 | - $this->level = $level; |
|
93 | - } |
|
72 | + /** |
|
73 | + * Workflow constructor. |
|
74 | + * |
|
75 | + * @param LoggerInterface $logger Main logger |
|
76 | + * @param FormatterInterface $formatter Workflow records formatter |
|
77 | + * @param \DateTimeZone $timezone Current timezone |
|
78 | + * @param string $name Workflow name |
|
79 | + * @param int|string $level Workflow level code |
|
80 | + */ |
|
81 | + public function __construct( |
|
82 | + LoggerInterface $logger, |
|
83 | + FormatterInterface $formatter, |
|
84 | + \DateTimeZone $timezone, |
|
85 | + $name, |
|
86 | + $level |
|
87 | + ) { |
|
88 | + $this->logger = $logger; |
|
89 | + $this->formatter = $formatter; |
|
90 | + $this->timezone = $timezone; |
|
91 | + $this->name = (string)$name; |
|
92 | + $this->level = $level; |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * @return \DateTime |
|
97 | - */ |
|
98 | - protected function getCurrentDateTime() |
|
99 | - { |
|
100 | - $time = new \DateTime(null, $this->timezone); |
|
101 | - $time->setTimezone($this->timezone); |
|
95 | + /** |
|
96 | + * @return \DateTime |
|
97 | + */ |
|
98 | + protected function getCurrentDateTime() |
|
99 | + { |
|
100 | + $time = new \DateTime(null, $this->timezone); |
|
101 | + $time->setTimezone($this->timezone); |
|
102 | 102 | |
103 | - return $time; |
|
104 | - } |
|
103 | + return $time; |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * @return string |
|
108 | - */ |
|
109 | - public function getName() |
|
110 | - { |
|
111 | - return $this->name; |
|
112 | - } |
|
106 | + /** |
|
107 | + * @return string |
|
108 | + */ |
|
109 | + public function getName() |
|
110 | + { |
|
111 | + return $this->name; |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * @return int|string |
|
116 | - */ |
|
117 | - public function getLevel() |
|
118 | - { |
|
119 | - return $this->level; |
|
120 | - } |
|
114 | + /** |
|
115 | + * @return int|string |
|
116 | + */ |
|
117 | + public function getLevel() |
|
118 | + { |
|
119 | + return $this->level; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Gets the name of the logging level. |
|
124 | - * |
|
125 | - * @param string $level |
|
126 | - * @return string |
|
127 | - * @throws LevelIsNotDefinedException |
|
128 | - */ |
|
129 | - public function getLevelName($level) |
|
130 | - { |
|
131 | - if (!isset(static::$levels[$level])) { |
|
132 | - throw LevelIsNotDefinedException::create($level, static::$levels); |
|
133 | - } |
|
122 | + /** |
|
123 | + * Gets the name of the logging level. |
|
124 | + * |
|
125 | + * @param string $level |
|
126 | + * @return string |
|
127 | + * @throws LevelIsNotDefinedException |
|
128 | + */ |
|
129 | + public function getLevelName($level) |
|
130 | + { |
|
131 | + if (!isset(static::$levels[$level])) { |
|
132 | + throw LevelIsNotDefinedException::create($level, static::$levels); |
|
133 | + } |
|
134 | 134 | |
135 | - return static::$levels[$level]; |
|
136 | - } |
|
135 | + return static::$levels[$level]; |
|
136 | + } |
|
137 | 137 | |
138 | - /** |
|
139 | - * Logs with a workflow level and with all workflow records |
|
140 | - * |
|
141 | - * @param string $message The log message |
|
142 | - * @param array $context The log context |
|
143 | - * @return void |
|
144 | - */ |
|
145 | - public function finish($message = '', array $context = []) |
|
146 | - { |
|
147 | - $message .= $message === '' ? '' : "\n\n"; |
|
148 | - $message .= "Workflow: {$this->getName()}\n"; |
|
138 | + /** |
|
139 | + * Logs with a workflow level and with all workflow records |
|
140 | + * |
|
141 | + * @param string $message The log message |
|
142 | + * @param array $context The log context |
|
143 | + * @return void |
|
144 | + */ |
|
145 | + public function finish($message = '', array $context = []) |
|
146 | + { |
|
147 | + $message .= $message === '' ? '' : "\n\n"; |
|
148 | + $message .= "Workflow: {$this->getName()}\n"; |
|
149 | 149 | |
150 | - foreach ($this->records as $record) { |
|
151 | - $message .= $this->formatter->format($record); |
|
152 | - } |
|
150 | + foreach ($this->records as $record) { |
|
151 | + $message .= $this->formatter->format($record); |
|
152 | + } |
|
153 | 153 | |
154 | - $this->logger->log($this->level, $message, $context); |
|
155 | - } |
|
154 | + $this->logger->log($this->level, $message, $context); |
|
155 | + } |
|
156 | 156 | |
157 | - /** |
|
158 | - * Logs workflow record with an arbitrary level. |
|
159 | - * |
|
160 | - * @param int $level The logging level |
|
161 | - * @param string $message The log message |
|
162 | - * @param array $context The log context |
|
163 | - * @return void |
|
164 | - * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
165 | - */ |
|
166 | - public function log($level, $message, array $context = []) |
|
167 | - { |
|
168 | - $this->records[] = new Record( |
|
169 | - $this->getCurrentDateTime(), |
|
170 | - $message, |
|
171 | - $this->getLevelName($level), |
|
172 | - $context |
|
173 | - ); |
|
174 | - } |
|
157 | + /** |
|
158 | + * Logs workflow record with an arbitrary level. |
|
159 | + * |
|
160 | + * @param int $level The logging level |
|
161 | + * @param string $message The log message |
|
162 | + * @param array $context The log context |
|
163 | + * @return void |
|
164 | + * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
165 | + */ |
|
166 | + public function log($level, $message, array $context = []) |
|
167 | + { |
|
168 | + $this->records[] = new Record( |
|
169 | + $this->getCurrentDateTime(), |
|
170 | + $message, |
|
171 | + $this->getLevelName($level), |
|
172 | + $context |
|
173 | + ); |
|
174 | + } |
|
175 | 175 | |
176 | - /** |
|
177 | - * System is unusable. |
|
178 | - * |
|
179 | - * @param string $message The log message |
|
180 | - * @param array $context The log context |
|
181 | - * @return void |
|
182 | - * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
183 | - */ |
|
184 | - public function emergency($message, array $context = []) |
|
185 | - { |
|
186 | - $this->log(self::EMERGENCY, $message, $context); |
|
187 | - } |
|
176 | + /** |
|
177 | + * System is unusable. |
|
178 | + * |
|
179 | + * @param string $message The log message |
|
180 | + * @param array $context The log context |
|
181 | + * @return void |
|
182 | + * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
183 | + */ |
|
184 | + public function emergency($message, array $context = []) |
|
185 | + { |
|
186 | + $this->log(self::EMERGENCY, $message, $context); |
|
187 | + } |
|
188 | 188 | |
189 | - /** |
|
190 | - * Action must be taken immediately. |
|
191 | - * |
|
192 | - * Example: Entire website down, database unavailable, etc. This should |
|
193 | - * trigger the SMS alerts and wake you up. |
|
194 | - * |
|
195 | - * @param string $message The log message |
|
196 | - * @param array $context The log context |
|
197 | - * @return void |
|
198 | - * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
199 | - */ |
|
200 | - public function alert($message, array $context = []) |
|
201 | - { |
|
202 | - $this->log(self::ALERT, $message, $context); |
|
203 | - } |
|
189 | + /** |
|
190 | + * Action must be taken immediately. |
|
191 | + * |
|
192 | + * Example: Entire website down, database unavailable, etc. This should |
|
193 | + * trigger the SMS alerts and wake you up. |
|
194 | + * |
|
195 | + * @param string $message The log message |
|
196 | + * @param array $context The log context |
|
197 | + * @return void |
|
198 | + * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
199 | + */ |
|
200 | + public function alert($message, array $context = []) |
|
201 | + { |
|
202 | + $this->log(self::ALERT, $message, $context); |
|
203 | + } |
|
204 | 204 | |
205 | - /** |
|
206 | - * Critical conditions. |
|
207 | - * |
|
208 | - * Example: Application component unavailable, unexpected exception. |
|
209 | - * |
|
210 | - * @param string $message The log message |
|
211 | - * @param array $context The log context |
|
212 | - * @return void |
|
213 | - * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
214 | - */ |
|
215 | - public function critical($message, array $context = []) |
|
216 | - { |
|
217 | - $this->log(self::CRITICAL, $message, $context); |
|
218 | - } |
|
205 | + /** |
|
206 | + * Critical conditions. |
|
207 | + * |
|
208 | + * Example: Application component unavailable, unexpected exception. |
|
209 | + * |
|
210 | + * @param string $message The log message |
|
211 | + * @param array $context The log context |
|
212 | + * @return void |
|
213 | + * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
214 | + */ |
|
215 | + public function critical($message, array $context = []) |
|
216 | + { |
|
217 | + $this->log(self::CRITICAL, $message, $context); |
|
218 | + } |
|
219 | 219 | |
220 | - /** |
|
221 | - * Runtime errors that do not require immediate action but should typically |
|
222 | - * be logged and monitored. |
|
223 | - * |
|
224 | - * @param string $message The log message |
|
225 | - * @param array $context The log context |
|
226 | - * @return void |
|
227 | - * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
228 | - */ |
|
229 | - public function error($message, array $context = []) |
|
230 | - { |
|
231 | - $this->log(self::ERROR, $message, $context); |
|
232 | - } |
|
220 | + /** |
|
221 | + * Runtime errors that do not require immediate action but should typically |
|
222 | + * be logged and monitored. |
|
223 | + * |
|
224 | + * @param string $message The log message |
|
225 | + * @param array $context The log context |
|
226 | + * @return void |
|
227 | + * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
228 | + */ |
|
229 | + public function error($message, array $context = []) |
|
230 | + { |
|
231 | + $this->log(self::ERROR, $message, $context); |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * Exceptional occurrences that are not errors. |
|
236 | - * |
|
237 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
238 | - * that are not necessarily wrong. |
|
239 | - * |
|
240 | - * @param string $message The log message |
|
241 | - * @param array $context The log context |
|
242 | - * @return void |
|
243 | - * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
244 | - */ |
|
245 | - public function warning($message, array $context = []) |
|
246 | - { |
|
247 | - $this->log(self::WARNING, $message, $context); |
|
248 | - } |
|
234 | + /** |
|
235 | + * Exceptional occurrences that are not errors. |
|
236 | + * |
|
237 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
238 | + * that are not necessarily wrong. |
|
239 | + * |
|
240 | + * @param string $message The log message |
|
241 | + * @param array $context The log context |
|
242 | + * @return void |
|
243 | + * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
244 | + */ |
|
245 | + public function warning($message, array $context = []) |
|
246 | + { |
|
247 | + $this->log(self::WARNING, $message, $context); |
|
248 | + } |
|
249 | 249 | |
250 | - /** |
|
251 | - * Normal but significant events. |
|
252 | - * |
|
253 | - * @param string $message The log message |
|
254 | - * @param array $context The log context |
|
255 | - * @return void |
|
256 | - * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
257 | - */ |
|
258 | - public function notice($message, array $context = []) |
|
259 | - { |
|
260 | - $this->log(self::NOTICE, $message, $context); |
|
261 | - } |
|
250 | + /** |
|
251 | + * Normal but significant events. |
|
252 | + * |
|
253 | + * @param string $message The log message |
|
254 | + * @param array $context The log context |
|
255 | + * @return void |
|
256 | + * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
257 | + */ |
|
258 | + public function notice($message, array $context = []) |
|
259 | + { |
|
260 | + $this->log(self::NOTICE, $message, $context); |
|
261 | + } |
|
262 | 262 | |
263 | - /** |
|
264 | - * Interesting events. |
|
265 | - * |
|
266 | - * Example: User logs in, SQL logs. |
|
267 | - * |
|
268 | - * @param string $message The log message |
|
269 | - * @param array $context The log context |
|
270 | - * @return void |
|
271 | - * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
272 | - */ |
|
273 | - public function info($message, array $context = []) |
|
274 | - { |
|
275 | - $this->log(self::INFO, $message, $context); |
|
276 | - } |
|
263 | + /** |
|
264 | + * Interesting events. |
|
265 | + * |
|
266 | + * Example: User logs in, SQL logs. |
|
267 | + * |
|
268 | + * @param string $message The log message |
|
269 | + * @param array $context The log context |
|
270 | + * @return void |
|
271 | + * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
272 | + */ |
|
273 | + public function info($message, array $context = []) |
|
274 | + { |
|
275 | + $this->log(self::INFO, $message, $context); |
|
276 | + } |
|
277 | 277 | |
278 | - /** |
|
279 | - * Detailed debug information. |
|
280 | - * |
|
281 | - * @param string $message The log message |
|
282 | - * @param array $context The log context |
|
283 | - * @return void |
|
284 | - * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
285 | - */ |
|
286 | - public function debug($message, array $context = []) |
|
287 | - { |
|
288 | - $this->log(self::DEBUG, $message, $context); |
|
289 | - } |
|
278 | + /** |
|
279 | + * Detailed debug information. |
|
280 | + * |
|
281 | + * @param string $message The log message |
|
282 | + * @param array $context The log context |
|
283 | + * @return void |
|
284 | + * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
|
285 | + */ |
|
286 | + public function debug($message, array $context = []) |
|
287 | + { |
|
288 | + $this->log(self::DEBUG, $message, $context); |
|
289 | + } |
|
290 | 290 | } |
@@ -12,8 +12,7 @@ discard block |
||
12 | 12 | * @package Yep\WorkflowLogger |
13 | 13 | * @author Martin Zeman (Zemistr) <[email protected]> |
14 | 14 | */ |
15 | -class Workflow implements LoggerInterface |
|
16 | -{ |
|
15 | +class Workflow implements LoggerInterface { |
|
17 | 16 | const EMERGENCY = 'emergency'; |
18 | 17 | const ALERT = 'alert'; |
19 | 18 | const CRITICAL = 'critical'; |
@@ -95,8 +94,7 @@ discard block |
||
95 | 94 | /** |
96 | 95 | * @return \DateTime |
97 | 96 | */ |
98 | - protected function getCurrentDateTime() |
|
99 | - { |
|
97 | + protected function getCurrentDateTime() { |
|
100 | 98 | $time = new \DateTime(null, $this->timezone); |
101 | 99 | $time->setTimezone($this->timezone); |
102 | 100 | |
@@ -106,16 +104,14 @@ discard block |
||
106 | 104 | /** |
107 | 105 | * @return string |
108 | 106 | */ |
109 | - public function getName() |
|
110 | - { |
|
107 | + public function getName() { |
|
111 | 108 | return $this->name; |
112 | 109 | } |
113 | 110 | |
114 | 111 | /** |
115 | 112 | * @return int|string |
116 | 113 | */ |
117 | - public function getLevel() |
|
118 | - { |
|
114 | + public function getLevel() { |
|
119 | 115 | return $this->level; |
120 | 116 | } |
121 | 117 | |
@@ -126,8 +122,7 @@ discard block |
||
126 | 122 | * @return string |
127 | 123 | * @throws LevelIsNotDefinedException |
128 | 124 | */ |
129 | - public function getLevelName($level) |
|
130 | - { |
|
125 | + public function getLevelName($level) { |
|
131 | 126 | if (!isset(static::$levels[$level])) { |
132 | 127 | throw LevelIsNotDefinedException::create($level, static::$levels); |
133 | 128 | } |
@@ -142,8 +137,7 @@ discard block |
||
142 | 137 | * @param array $context The log context |
143 | 138 | * @return void |
144 | 139 | */ |
145 | - public function finish($message = '', array $context = []) |
|
146 | - { |
|
140 | + public function finish($message = '', array $context = []) { |
|
147 | 141 | $message .= $message === '' ? '' : "\n\n"; |
148 | 142 | $message .= "Workflow: {$this->getName()}\n"; |
149 | 143 | |
@@ -163,8 +157,7 @@ discard block |
||
163 | 157 | * @return void |
164 | 158 | * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
165 | 159 | */ |
166 | - public function log($level, $message, array $context = []) |
|
167 | - { |
|
160 | + public function log($level, $message, array $context = []) { |
|
168 | 161 | $this->records[] = new Record( |
169 | 162 | $this->getCurrentDateTime(), |
170 | 163 | $message, |
@@ -181,8 +174,7 @@ discard block |
||
181 | 174 | * @return void |
182 | 175 | * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
183 | 176 | */ |
184 | - public function emergency($message, array $context = []) |
|
185 | - { |
|
177 | + public function emergency($message, array $context = []) { |
|
186 | 178 | $this->log(self::EMERGENCY, $message, $context); |
187 | 179 | } |
188 | 180 | |
@@ -197,8 +189,7 @@ discard block |
||
197 | 189 | * @return void |
198 | 190 | * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
199 | 191 | */ |
200 | - public function alert($message, array $context = []) |
|
201 | - { |
|
192 | + public function alert($message, array $context = []) { |
|
202 | 193 | $this->log(self::ALERT, $message, $context); |
203 | 194 | } |
204 | 195 | |
@@ -212,8 +203,7 @@ discard block |
||
212 | 203 | * @return void |
213 | 204 | * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
214 | 205 | */ |
215 | - public function critical($message, array $context = []) |
|
216 | - { |
|
206 | + public function critical($message, array $context = []) { |
|
217 | 207 | $this->log(self::CRITICAL, $message, $context); |
218 | 208 | } |
219 | 209 | |
@@ -226,8 +216,7 @@ discard block |
||
226 | 216 | * @return void |
227 | 217 | * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
228 | 218 | */ |
229 | - public function error($message, array $context = []) |
|
230 | - { |
|
219 | + public function error($message, array $context = []) { |
|
231 | 220 | $this->log(self::ERROR, $message, $context); |
232 | 221 | } |
233 | 222 | |
@@ -242,8 +231,7 @@ discard block |
||
242 | 231 | * @return void |
243 | 232 | * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
244 | 233 | */ |
245 | - public function warning($message, array $context = []) |
|
246 | - { |
|
234 | + public function warning($message, array $context = []) { |
|
247 | 235 | $this->log(self::WARNING, $message, $context); |
248 | 236 | } |
249 | 237 | |
@@ -255,8 +243,7 @@ discard block |
||
255 | 243 | * @return void |
256 | 244 | * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
257 | 245 | */ |
258 | - public function notice($message, array $context = []) |
|
259 | - { |
|
246 | + public function notice($message, array $context = []) { |
|
260 | 247 | $this->log(self::NOTICE, $message, $context); |
261 | 248 | } |
262 | 249 | |
@@ -270,8 +257,7 @@ discard block |
||
270 | 257 | * @return void |
271 | 258 | * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
272 | 259 | */ |
273 | - public function info($message, array $context = []) |
|
274 | - { |
|
260 | + public function info($message, array $context = []) { |
|
275 | 261 | $this->log(self::INFO, $message, $context); |
276 | 262 | } |
277 | 263 | |
@@ -283,8 +269,7 @@ discard block |
||
283 | 269 | * @return void |
284 | 270 | * @throws \Yep\WorkflowLogger\Exception\LevelIsNotDefinedException |
285 | 271 | */ |
286 | - public function debug($message, array $context = []) |
|
287 | - { |
|
272 | + public function debug($message, array $context = []) { |
|
288 | 273 | $this->log(self::DEBUG, $message, $context); |
289 | 274 | } |
290 | 275 | } |