From 019dca35966801d3b9e2c5950df9c73ae83847cb Mon Sep 17 00:00:00 2001 From: frytimo Date: Thu, 9 Oct 2025 15:53:45 -0300 Subject: [PATCH] Add helper functions to parent service class. (#7550) * Add helper functions to parent service class. Removed existing functions from base_websocket_system class. * Update service.php --- .../classes/base_websocket_system_service.php | 16 ---- resources/classes/service.php | 81 ++++++++++++++++--- 2 files changed, 71 insertions(+), 26 deletions(-) diff --git a/core/websockets/resources/classes/base_websocket_system_service.php b/core/websockets/resources/classes/base_websocket_system_service.php index 0639dafa1c..27c65dc102 100644 --- a/core/websockets/resources/classes/base_websocket_system_service.php +++ b/core/websockets/resources/classes/base_websocket_system_service.php @@ -156,22 +156,6 @@ abstract class base_websocket_system_service extends service implements websocke return 0; } - protected function debug(string $message) { - self::log($message, LOG_DEBUG); - } - - protected function warn(string $message) { - self::log($message, LOG_WARNING); - } - - protected function error(string $message) { - self::log($message, LOG_ERR); - } - - protected function info(string $message) { - self::log($message, LOG_INFO); - } - /** * Connects to the web socket server using a websocket_client object * @return bool True if connected and False if not able to connect diff --git a/resources/classes/service.php b/resources/classes/service.php index 6899f5b4c0..53f19cc69c 100644 --- a/resources/classes/service.php +++ b/resources/classes/service.php @@ -813,16 +813,6 @@ abstract class service { } } - //TODO remove updated settings object after merge - if (file_exists( __DIR__ . '/settings.php')) { - require_once __DIR__ . '/settings.php'; - } - - //TODO remove global functions after merge - if (file_exists(dirname(__DIR__).'/functions.php')) { - require_once dirname(__DIR__).'/functions.php'; - } - //create the config object if not already created if (self::$config === null) { self::$config = new config(self::$config_file); @@ -841,6 +831,77 @@ abstract class service { return $service; } + /** + * Send a debug message to the log + * @param string $message + * @return void + */ + protected function debug(string $message = ''): void { + self::log($message, LOG_DEBUG); + } + + /** + * Send an info message to the log + * @param string $message + * @return void + */ + protected function info(string $message = ''): void { + self::log($message, LOG_INFO); + } + + /** + * Send a notice message to the log + * @param string $message + * @return void + */ + protected function notice(string $message = ''): void { + self::log($message, LOG_NOTICE); + } + + /** + * Send a warning message to the log + * @param string $message + * @return void + */ + protected function warning(string $message = ''): void { + self::log($message, LOG_WARNING); + } + + /** + * Send an error message to the log + * @param string $message + * @return void + */ + protected function error(string $message = ''): void { + self::log($message, LOG_ERR); + } + + /** + * Send a critical message to the log + * @param string $message + * @return void + */ + protected function critical(string $message = ''): void { + self::log($message, LOG_CRIT); + } + + /** + * Sends an alert message to the log + * @param string $message + * @return void + */ + protected function alert(string $message = ''): void { + self::log($message, LOG_ALERT); + } + + /** + * Sends an emergency message to the log + * @param string $message + * @return void + */ + protected function emergency(string $message = ''): void { + self::log($message, LOG_EMERG); + } } /*