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 | public static function getSubscribedEvents(): array |
||
79 | |||
80 | /** |
||
81 | * Adds a log message using the level defined in the mappings. |
||
82 | * |
||
83 | * @param mixed[] $context |
||
84 | */ |
||
85 | public function log(AbstractGitEvent $gitEvent, string $message, array $context = []): void |
||
94 | |||
95 | public function onPrepare(GitPrepareEvent $gitPrepareEvent): void |
||
99 | |||
100 | public function handleOutput(GitOutputEvent $gitOutputEvent): void |
||
105 | |||
106 | public function onSuccess(GitSuccessEvent $gitSuccessEvent): void |
||
110 | |||
111 | public function onError(GitErrorEvent $gitErrorEvent): void |
||
115 | |||
116 | public function onBypass(GitBypassEvent $gitBypassEvent): void |
||
120 | } |
||
121 |