diff --git a/plugin/shared/Helpers/PluginLogger.php b/plugin/shared/Helpers/PluginLogger.php index e7d2b54..ea368d9 100644 --- a/plugin/shared/Helpers/PluginLogger.php +++ b/plugin/shared/Helpers/PluginLogger.php @@ -7,7 +7,8 @@ use Monolog\Formatter\LineFormatter; use Transbank\Plugin\Model\LogConfig; -final class PluginLogger implements ILogger { +final class PluginLogger implements ILogger +{ const CACHE_LOG_NAME = 'transbank_log_file_name'; @@ -21,7 +22,8 @@ final class PluginLogger implements ILogger { * output format : "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n" * @param Throwable $e */ - public function __construct(LogConfig $config) { + public function __construct(LogConfig $config) + { $this->config = $config; $logFilePath = $this->getLogFilePath(); @@ -34,8 +36,11 @@ private function initializeLogger(string $logFilePath) $output = "%datetime% > %level_name% > %message% %context% %extra%\n"; $formatter = new LineFormatter($output, $dateFormat); - $stream = new RotatingFileHandler($logFilePath, - 100, Logger::DEBUG); + $stream = new RotatingFileHandler( + $logFilePath, + 100, + Logger::DEBUG + ); $stream->setFormatter($formatter); $this->logger = new Logger('transbank'); @@ -56,11 +61,13 @@ private function getLogFilePath(): string return $logDir . $logFileName; } - public function getLogger(){ + public function getLogger() + { return $this->logger; } - public function getConfig(){ + public function getConfig() + { return $this->config; } @@ -81,7 +88,7 @@ public function logError($msg) public function getInfo() { - $files = glob($this->config->getLogDir().'/*.log'); + $files = glob($this->config->getLogDir() . '/*.log'); if (!$files) { return [ 'dir' => $this->config->getLogDir(), @@ -94,7 +101,7 @@ public function getInfo() arsort($files); $logs = []; - foreach($files as $key=>$value) { + foreach ($files as $key => $value) { $logs[] = [ "filename" => basename($key), "modified" => $value @@ -114,7 +121,7 @@ public function getLogDetail($filename, $replaceNewline = false) if ($filename == '') { return []; } - $fle = $this->config->getLogDir().'/'.$filename; + $fle = $this->config->getLogDir() . '/' . $filename; $content = file_get_contents($fle); if ($replaceNewline && $content !== false) { $content = str_replace("\n", '#@#', $content);