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

chore: prepare release 1.9.1 #243

Merged
merged 26 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1a2ee6b
feat: add method getLogFileName
mastudillot Jun 2, 2024
d1de9d9
feat: add constant CACHE_LOG_NAME
mastudillot Jun 2, 2024
e0e3f52
feat: add method saveLogFileNameInCache
mastudillot Jun 2, 2024
3153077
feat: add method getLogDir
mastudillot Jun 2, 2024
ba7d7a0
feat: add method getLogFileNameFromCache
mastudillot Jun 2, 2024
3450a2e
fix: save in cache only the log file name
mastudillot Jun 2, 2024
0a6ea6e
fix: remove incompatible return type
mastudillot Jun 2, 2024
3778e0f
fix: use new cache name
mastudillot Jun 2, 2024
834b2ae
fix: add dot in log file extension
mastudillot Jun 2, 2024
c2f01e7
fix: duplicated record in log list
mastudillot Jun 2, 2024
a7a1b4c
feat: add method getLogFilePath
mastudillot Jun 2, 2024
f7943f2
refactor: implement method getLogFilePath
mastudillot Jun 2, 2024
459cda4
feat: add method initializeLogger
mastudillot Jun 2, 2024
94bc7b3
refactor: implement method initializeLogger
mastudillot Jun 2, 2024
e5734a8
style: format file
mastudillot Jun 2, 2024
b1e750c
fix: warning when input is null
mastudillot Jun 3, 2024
bfb36e8
style: format file
mastudillot Jun 3, 2024
8b10ce5
refactor: return empty string when input is null
mastudillot Jun 3, 2024
0dfc8e7
Merge pull request #239 from TransbankDevelopers/fix/warning-when-inp…
mastudillot Jun 3, 2024
b35f6a9
Merge pull request #240 from TransbankDevelopers/fix/save-in-cache-on…
mastudillot Jun 3, 2024
cbf16aa
fix: timezone for logs
mastudillot Jun 3, 2024
1b73592
feat: add timezone in format for logs
mastudillot Jun 3, 2024
beb4d79
Merge pull request #241 from TransbankDevelopers/fix/timezone-for-logs
mastudillot Jun 3, 2024
ba8109b
chore: separate asset uploads
mastudillot Jun 3, 2024
862bdb2
Merge pull request #242 from TransbankDevelopers/chore/fix-upload-ass…
mastudillot Jun 3, 2024
819ee11
docs: update readme
mastudillot Jun 3, 2024
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
19 changes: 12 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,21 @@ jobs:
env:
WP_ORG_PASSWORD: ${{ secrets.WP_ORG_PASSWORD }}
TAG: ${{ github.event.release.tag_name }}
- name: Upload assets
- name: Upload transbank-webpay-plus-rest.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: |
transbank-webpay-plus-rest.zip
transbank-webpay-plus-rest-guzzle7.zip
asset_name: |
transbank-webpay-plus-rest.zip
transbank-webpay-plus-rest-guzzle7.zip
asset_path: transbank-webpay-plus-rest.zip
asset_name: transbank-webpay-plus-rest.zip
asset_content_type: application/zip
- name: Upload transbank-webpay-plus-rest-guzzle7.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: transbank-webpay-plus-rest-guzzle7.zip
asset_name: transbank-webpay-plus-rest-guzzle7.zip
asset_content_type: application/zip
12 changes: 12 additions & 0 deletions plugin/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ Recibe pagos en línea con tarjetas de crédito, débito y prepago en tu WooComm
Recibe pagos en línea con tarjetas de crédito, débito y prepago en tu WooCommerce a través de Webpay Plus y Webpay Oneclick

== Changelog ==
= 1.9.1 =
* Se arregla un mensaje de warning provocado por la función maskData en PHP mayor o igual a 8.x.
* Se arregla un problema que impedía encontrar el archivo de log al migrar el sitio de un servidor a otro.
* Se arregla la zona horaria de los logs. Se usa la que este configurada en el ecommerce del comercio.
* Se arregla un problema que provocaba registros duplicados en el selector de archivos logs de la vista registros.

= 1.9.0 =
* Se agrega la opción de poder seleccionar el archivo log en la sección de registros del menú de configuración.
* Se agrega la funcionalidad para que se muestren las tarjetas registradas de Oneclick dependiendo del entorno.
Expand Down Expand Up @@ -163,6 +169,12 @@ Arreglado:
* Initial release.

== Upgrade Notice ==
= 1.9.1 =
* Se arregla un mensaje de warning provocado por la función maskData en PHP mayor o igual a 8.x.
* Se arregla un problema que impedía encontrar el archivo de log al migrar el sitio de un servidor a otro.
* Se arregla la zona horaria de los logs. Se usa la que este configurada en el ecommerce del comercio.
* Se arregla un problema que provocaba registros duplicados en el selector de archivos logs de la vista registros.

= 1.9.0 =
* Se agrega la opción de poder seleccionar el archivo log en la sección de registros del menú de configuración.
* Se agrega la funcionalidad para que se muestren las tarjetas registradas de Oneclick dependiendo del entorno.
Expand Down
87 changes: 68 additions & 19 deletions plugin/shared/Helpers/PluginLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

namespace Transbank\Plugin\Helpers;

use DateTimeZone;
use Monolog\Logger;
use Monolog\Handler\RotatingFileHandler;
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';

private $logger;
private $config;

Expand All @@ -18,32 +23,54 @@ 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;
$logDir = $this->config->getLogDir();
$cacheLogName = 'transbank_log_name';
$logFile = get_transient($cacheLogName);
if (!$logFile) {
$uniqueId = uniqid('', true);
$logFile = "{$logDir}/log_transbank_{$uniqueId}.log";
$expireTime = strtotime('tomorrow') - time();
set_transient($cacheLogName, $logFile, $expireTime);
}
$dateFormat = "Y-m-d H:i:s";

$logFilePath = $this->getLogFilePath();
$this->initializeLogger($logFilePath);
}

private function initializeLogger(string $logFilePath)
{
$ecommerceTz = new DateTimeZone(wc_timezone_string());
$dateFormat = "Y-m-d H:i:s P";
$output = "%datetime% > %level_name% > %message% %context% %extra%\n";
$formatter = new LineFormatter($output, $dateFormat);
$stream = new RotatingFileHandler($logFile,
100, Logger::DEBUG);

$stream = new RotatingFileHandler(
$logFilePath,
100,
Logger::DEBUG
);
$stream->setFormatter($formatter);

$this->logger = new Logger('transbank');
$this->logger->setTimezone($ecommerceTz);
$this->logger->pushHandler($stream);
}

public function getLogger(){
private function getLogFilePath(): string
{
$logFileName = $this->getLogFileNameFromCache();

if (!$logFileName) {
$logFileName = $this->getLogFileName();
$expireTime = strtotime('tomorrow') - time();
$this->saveLogFileNameInCache($logFileName, $expireTime);
}

$logDir = $this->getLogDir();
return $logDir . $logFileName;
}

public function getLogger()
{
return $this->logger;
}

public function getConfig(){
public function getConfig()
{
return $this->config;
}

Expand All @@ -64,7 +91,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(),
Expand All @@ -77,7 +104,7 @@ public function getInfo()
arsort($files);

$logs = [];
foreach($files as $key=>$value) {
foreach ($files as $key => $value) {
$logs[] = [
"filename" => basename($key),
"modified" => $value
Expand All @@ -97,7 +124,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);
Expand All @@ -122,4 +149,26 @@ private function formatBytes($path)
}
return $bytes;
}

private function getLogDir(): string
{
$logDir = $this->config->getLogDir();
return trailingslashit($logDir);
}

private function getLogFileName(): string
{
$uniqueId = uniqid('', true);
return 'log_transbank_' . $uniqueId . '.log';
}

private function getLogFileNameFromCache()
{
return get_transient(self::CACHE_LOG_NAME);
}

private function saveLogFileNameInCache(string $logFileName, int $expireTime)
{
set_transient(self::CACHE_LOG_NAME, $logFileName, $expireTime);
}
}
Loading
Loading