From 145c2eef9198b35d3d9889880c706864bb7d6ae2 Mon Sep 17 00:00:00 2001 From: KwangSeob Jeong Date: Fri, 3 Feb 2023 22:50:20 +0900 Subject: [PATCH] fixed #499 - added Monolog V3 Handler --- src/JiraClient.php | 13 ++++++++++++- src/NoOperationMonologHandlerV3.php | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/NoOperationMonologHandlerV3.php diff --git a/src/JiraClient.php b/src/JiraClient.php index ad6ccbf..fd2ee40 100644 --- a/src/JiraClient.php +++ b/src/JiraClient.php @@ -92,7 +92,18 @@ public function __construct(ConfigurationInterface $configuration = null, Logger } } else { $this->log = new Logger('JiraClient'); - $this->log->pushHandler(new NoOperationMonologHandler()); + + // Monolog 3.x has a breaking change, so I have to add this dirty code. + $ver = \Composer\InstalledVersions::getVersion('monolog/monolog'); + $major = intval(explode('.', $ver)[0]); + + if ($major === 2) { + $this->log->pushHandler(new NoOperationMonologHandler()); + } elseif ($major === 3) { + $this->log->pushHandler(new NoOperationMonologHandlerV3()); + } else { + throw new JiraException("Unsupported Monolog version $major"); + } } $this->http_response = 200; diff --git a/src/NoOperationMonologHandlerV3.php b/src/NoOperationMonologHandlerV3.php new file mode 100644 index 0000000..e874d5f --- /dev/null +++ b/src/NoOperationMonologHandlerV3.php @@ -0,0 +1,14 @@ +