From f7e202f04ec2a33174a3bb62ab7d8b14f8575a23 Mon Sep 17 00:00:00 2001 From: nguyenanhung Date: Tue, 15 Aug 2023 16:04:33 +0700 Subject: [PATCH 1/2] Release version 3.0.8 --- helpers/system_notification.php | 6 ++++++ src/ProjectInterface.php | 4 ++-- src/SystemNotification.php | 33 ++++++++------------------------- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/helpers/system_notification.php b/helpers/system_notification.php index a2cfd6b..b7e502f 100644 --- a/helpers/system_notification.php +++ b/helpers/system_notification.php @@ -7,6 +7,12 @@ * Date: 2/12/20 * Time: 11:00 */ +if (!function_exists('system_notification_error_message')) { + function system_notification_error_message($e): string + { + return 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage(); + } +} if (!function_exists('system_notification_to_mantis')) { /** * Hàm gửi thông báo, cảnh báo hệ thống tới Mantis Bug Tracker diff --git a/src/ProjectInterface.php b/src/ProjectInterface.php index 14254ca..ac2bf2f 100644 --- a/src/ProjectInterface.php +++ b/src/ProjectInterface.php @@ -17,8 +17,8 @@ */ interface ProjectInterface { - const VERSION = '3.0.7'; - const LAST_MODIFIED = '2022-03-15'; + const VERSION = '3.0.8'; + const LAST_MODIFIED = '2022-08-15'; const AUTHOR_NAME = 'Hung Nguyen'; const AUTHOR_EMAIL = 'dev@nguyenanhung.com'; const PROJECT_NAME = 'Monitor Connector'; diff --git a/src/SystemNotification.php b/src/SystemNotification.php index 7696321..eb15fb6 100644 --- a/src/SystemNotification.php +++ b/src/SystemNotification.php @@ -57,16 +57,14 @@ public static function mantis(array $sdkConfig = array(), string $module = '', s ->setMonitorPassword($options['monitorPassword']) ->setProjectId($options['monitorProjectId']) ->mantis($monitorProjectName . $title . ' - ' . $module, $description); - return true; } } catch (Exception $e) { if (function_exists('log_message')) { - log_message('error', 'Error Message: ' . $e->getMessage()); + log_message('error', system_notification_error_message($e)); log_message('error', 'Error Trace As String: ' . $e->getTraceAsString()); } } - return false; } @@ -103,16 +101,14 @@ public static function slack(array $sdkConfig = array(), string $module = '', st $handle->setAttachMessage($attachMessage); } $handle->send(); - return true; } } catch (Exception $e) { if (function_exists('log_message')) { - log_message('error', 'Error Message: ' . $e->getMessage()); + log_message('error', system_notification_error_message($e)); log_message('error', 'Error Trace As String: ' . $e->getTraceAsString()); } } - return false; } @@ -143,20 +139,15 @@ public static function telegram(array $sdkConfig = array(), string $module = '', $chatId = $config['default_chat_id'] ?? null; } $handle = new TelegramMessenger(); - $handle->setSdkConfig($sdkConfig) - ->setChatId($chatId) - ->setMessage($message) - ->sendMessage(); - + $handle->setSdkConfig($sdkConfig)->setChatId($chatId)->setMessage($message)->sendMessage(); return true; } } catch (Exception $e) { if (function_exists('log_message')) { - log_message('error', 'Error Message: ' . $e->getMessage()); + log_message('error', system_notification_error_message($e)); log_message('error', 'Error Trace As String: ' . $e->getTraceAsString()); } } - return false; } @@ -191,20 +182,15 @@ public static function google_chat(array $sdkConfig = array(), string $module = $access_key = $config['access_key'] ?? null; $access_token = $config['access_token'] ?? null; $handle = new Notifier(); - $handle->setSpaceId($chatId) - ->setKey($access_key) - ->setToken($access_token) - ->setMessage($message); - + $handle->setSpaceId($chatId)->setKey($access_key)->setToken($access_token)->setMessage($message); return $handle->send(); } } catch (Exception $e) { if (function_exists('log_message')) { - log_message('error', 'Error Message: ' . $e->getMessage()); + log_message('error', system_notification_error_message($e)); log_message('error', 'Error Trace As String: ' . $e->getTraceAsString()); } } - return false; } @@ -234,18 +220,15 @@ public static function teams(array $sdkConfig = array(), string $module = '', st $title = $monitorProjectName . $module; $textMessage = $message; $teams = new MicrosoftTeamsConnector(); - $teams->setWebHook($webhookUrl) - ->simpleMessage($title, $textMessage); - + $teams->setWebHook($webhookUrl)->simpleMessage($title, $textMessage); return true; } } catch (Exception $e) { if (function_exists('log_message')) { - log_message('error', 'Error Message: ' . $e->getMessage()); + log_message('error', system_notification_error_message($e)); log_message('error', 'Error Trace As String: ' . $e->getTraceAsString()); } } - return false; } } From bef98f6a04a5e46e9b4ccc90c8bd5496f696ed4b Mon Sep 17 00:00:00 2001 From: nguyenanhung Date: Tue, 15 Aug 2023 16:05:42 +0700 Subject: [PATCH 2/2] Release version 3.0.8 --- helpers/system_notification.php | 4 ++-- src/SystemNotification.php | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/helpers/system_notification.php b/helpers/system_notification.php index b7e502f..a91044e 100644 --- a/helpers/system_notification.php +++ b/helpers/system_notification.php @@ -7,8 +7,8 @@ * Date: 2/12/20 * Time: 11:00 */ -if (!function_exists('system_notification_error_message')) { - function system_notification_error_message($e): string +if (!function_exists('_sn_helper_error_message_')) { + function _sn_helper_error_message_($e): string { return 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage(); } diff --git a/src/SystemNotification.php b/src/SystemNotification.php index eb15fb6..53336c4 100644 --- a/src/SystemNotification.php +++ b/src/SystemNotification.php @@ -61,7 +61,7 @@ public static function mantis(array $sdkConfig = array(), string $module = '', s } } catch (Exception $e) { if (function_exists('log_message')) { - log_message('error', system_notification_error_message($e)); + log_message('error', _sn_helper_error_message_($e)); log_message('error', 'Error Trace As String: ' . $e->getTraceAsString()); } } @@ -105,7 +105,7 @@ public static function slack(array $sdkConfig = array(), string $module = '', st } } catch (Exception $e) { if (function_exists('log_message')) { - log_message('error', system_notification_error_message($e)); + log_message('error', _sn_helper_error_message_($e)); log_message('error', 'Error Trace As String: ' . $e->getTraceAsString()); } } @@ -144,7 +144,7 @@ public static function telegram(array $sdkConfig = array(), string $module = '', } } catch (Exception $e) { if (function_exists('log_message')) { - log_message('error', system_notification_error_message($e)); + log_message('error', _sn_helper_error_message_($e)); log_message('error', 'Error Trace As String: ' . $e->getTraceAsString()); } } @@ -187,7 +187,7 @@ public static function google_chat(array $sdkConfig = array(), string $module = } } catch (Exception $e) { if (function_exists('log_message')) { - log_message('error', system_notification_error_message($e)); + log_message('error', _sn_helper_error_message_($e)); log_message('error', 'Error Trace As String: ' . $e->getTraceAsString()); } } @@ -225,7 +225,7 @@ public static function teams(array $sdkConfig = array(), string $module = '', st } } catch (Exception $e) { if (function_exists('log_message')) { - log_message('error', system_notification_error_message($e)); + log_message('error', _sn_helper_error_message_($e)); log_message('error', 'Error Trace As String: ' . $e->getTraceAsString()); } }