1 | <?php |
||
19 | final class GitLoggerEventSubscriber implements EventSubscriberInterface, LoggerAwareInterface |
||
20 | { |
||
21 | /** |
||
22 | * Mapping of event to log level. |
||
23 | * |
||
24 | * @var string[] |
||
25 | */ |
||
26 | private $logLevelMappings = [ |
||
27 | GitPrepareEvent::class => LogLevel::INFO, |
||
28 | GitOutputEvent::class => LogLevel::DEBUG, |
||
29 | GitSuccessEvent::class => LogLevel::INFO, |
||
30 | GitErrorEvent::class => LogLevel::ERROR, |
||
31 | GitBypassEvent::class => LogLevel::INFO, |
||
32 | ]; |
||
33 | |||
34 | /** |
||
35 | * @var LoggerInterface |
||
36 | */ |
||
37 | private $logger; |
||
38 | |||
39 | public function __construct(LoggerInterface $logger) |
||
43 | |||
44 | /** |
||
45 | * Required by interface |
||
46 | */ |
||
47 | public function setLogger(LoggerInterface $logger): void |
||
51 | |||
52 | public function setLogLevelMapping(string $eventName, string $logLevel): void |
||
56 | |||
57 | /** |
||
58 | * Returns the log level mapping for an event. |
||
59 | */ |
||
60 | public function getLogLevelMapping(string $eventName): string |
||
68 | |||
69 | /** |
||
70 | * @return int[][]|string[][] |
||
71 | */ |
||
72 | public static function getSubscribedEvents(): array |
||
82 | |||
83 | /** |
||
84 | * Adds a log message using the level defined in the mappings. |
||
85 | * |
||
86 | * @param mixed[] $context |
||
87 | */ |
||
88 | public function log(AbstractGitEvent $gitEvent, string $message, array $context = []): void |
||
97 | |||
98 | public function onPrepare(GitPrepareEvent $gitPrepareEvent): void |
||
102 | |||
103 | public function handleOutput(GitOutputEvent $gitOutputEvent): void |
||
108 | |||
109 | public function onSuccess(GitSuccessEvent $gitSuccessEvent): void |
||
113 | |||
114 | public function onError(GitErrorEvent $gitErrorEvent): void |
||
118 | |||
119 | public function onBypass(GitBypassEvent $gitBypassEvent): void |
||
123 | } |
||
124 |