Skip to content

Commit

Permalink
fixed #499 - added Monolog V3 Handler
Browse files Browse the repository at this point in the history
  • Loading branch information
lesstif committed Feb 3, 2023
1 parent 5dee03c commit 145c2ee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/JiraClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions src/NoOperationMonologHandlerV3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace JiraRestApi;

use Monolog\Handler\AbstractProcessingHandler;
use Monolog\LogRecord;

class NoOperationMonologHandlerV3 extends AbstractProcessingHandler
{
protected function write(LogRecord $record): void
{
// do nothing
}
}

0 comments on commit 145c2ee

Please sign in to comment.