From 8fd034e4ea0ea726d20376c4371c1e1a7dad4c46 Mon Sep 17 00:00:00 2001 From: Tony Coyle Date: Mon, 22 Apr 2024 16:24:16 +1200 Subject: [PATCH 1/2] Add environment variable flag to silence error_log on init. --- README.md | 4 ++++ src/DotenvVault.php | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 99ef313..469ad4b 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,10 @@ Yes. It is safe and recommended to do so. It contains your encrypted envs, and y No. It is the key that unlocks your encrypted environment variables. Be very careful who you share this key with. Do not let it leak. +#### Can I silence the logging? + +Yes. Set `DOTENV_VAULT_SILENT=true` in your environment. + ## Contributing 1. Fork it diff --git a/src/DotenvVault.php b/src/DotenvVault.php index 1ab8436..1ccf48d 100644 --- a/src/DotenvVault.php +++ b/src/DotenvVault.php @@ -180,7 +180,11 @@ public function load() public function _log($message) { - error_log("[dotenv-vault][INFO] {$message}"); + if (getenv('DOTENV_VAULT_SILENT') === 'true') { + return; + } + + error_log("[dotenv-vault][INFO] {$message}", 4); } public function _loadDotenv() @@ -236,7 +240,7 @@ public function _decryptVault() // Decrypt $decrypted = (new Decrypter())->decrypt($attrs['ciphertext'], $attrs['key']); - + // If successful, break the loop break; } catch (Exception $error) { From e6da3f9581790aba51122f1c7f2bd651e6377cb1 Mon Sep 17 00:00:00 2001 From: Tony Coyle Date: Thu, 30 Jan 2025 12:42:53 +1300 Subject: [PATCH 2/2] Removed environment flag and reverting to commenting out log until proper logging handling in place from upstream repository. --- README.md | 4 ---- src/DotenvVault.php | 6 +----- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/README.md b/README.md index 469ad4b..99ef313 100644 --- a/README.md +++ b/README.md @@ -139,10 +139,6 @@ Yes. It is safe and recommended to do so. It contains your encrypted envs, and y No. It is the key that unlocks your encrypted environment variables. Be very careful who you share this key with. Do not let it leak. -#### Can I silence the logging? - -Yes. Set `DOTENV_VAULT_SILENT=true` in your environment. - ## Contributing 1. Fork it diff --git a/src/DotenvVault.php b/src/DotenvVault.php index 1ccf48d..7740e1a 100644 --- a/src/DotenvVault.php +++ b/src/DotenvVault.php @@ -180,11 +180,7 @@ public function load() public function _log($message) { - if (getenv('DOTENV_VAULT_SILENT') === 'true') { - return; - } - - error_log("[dotenv-vault][INFO] {$message}", 4); +// error_log("[dotenv-vault][INFO] {$message}", 4); } public function _loadDotenv()