Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPAL-1251 attempt to replace laminas-log with monolog #1676

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion service-admin/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"laminas/laminas-config-aggregator": "^1.7",
"laminas/laminas-diactoros": "^2.8.0",
"laminas/laminas-form": "^3.0.1",
"laminas/laminas-log": "^2.13",
"monolog/monolog": "^3.4",
"laminas/laminas-math": "^3.4",
"laminas/laminas-permissions-rbac": "^3.2.0",
"laminas/laminas-router": "^3.7",
Expand Down
211 changes: 112 additions & 99 deletions service-admin/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions service-admin/src/App/src/Logging/LoggerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace App\Logging;

use Laminas\Log\Logger as LaminasLogger;
use Laminas\Log\Writer\Stream as StreamWriter;
use Monolog\Level;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;


/**
* Trait LoggerTrait
Expand All @@ -12,18 +14,18 @@
trait LoggerTrait
{
/**
* @var LaminasLogger
* @var Logger
*/
private $logger;

/**
* @return LaminasLogger $logger
* @return Logger $logger
*/
public function getLogger()
{
if (!$this->logger instanceof LaminasLogger) {
$this->logger = new LaminasLogger();
$this->logger->addWriter(new StreamWriter('php://stderr'));
if (!$this->logger instanceof Logger) {
$this->logger = new Logger('logger');
$this->logger->pushHandler(new StreamHandler('php://stderr', Level::Warning));
}

return $this->logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LoggingErrorListener
*/
public function __invoke(Throwable $error, ServerRequestInterface $_1, ResponseInterface $_2)
{
$this->getLogger()->err(sprintf(
$this->getLogger()->error(sprintf(
'%s in %s on line %s - %s',
$error->getMessage(),
$error->getFile(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private function fetchToken(ServerRequestInterface $request): string
};

/* If everything fails log and throw. */
$this->getLogger()->warn("Token not found");
$this->getLogger()->warning("Token not found");
throw new RuntimeException("Token not found.");
}

Expand All @@ -198,7 +198,7 @@ private function decodeToken(#[\SensitiveParameter] string $token): array
);
return (array) $decoded;
} catch (Exception $exception) {
$this->getLogger()->warn($exception->getMessage(), [$token]);
$this->getLogger()->warning($exception->getMessage(), [$token]);
throw $exception;
}
}
Expand Down
2 changes: 1 addition & 1 deletion service-api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"laminas/laminas-cache-storage-adapter-memory": "2.2.0",
"laminas/laminas-crypt": "^3.4",
"laminas/laminas-filter": "^2.12.0",
"laminas/laminas-log": "^2.13",
"monolog/monolog": "^3.4",
"laminas/laminas-math": "^3.4",
"laminas/laminas-mvc": "^3.2",
"laminas/laminas-mvc-i18n": "^2.0",
Expand Down
Loading