From 735dc7b33e5011cb68f8bf77dc65cc77e0ed768e Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 28 Oct 2024 19:47:20 -0400 Subject: [PATCH] Removed unused LoggingException --- .idea/inspectionProfiles/Project_Default.xml | 1 + src/LogLib/Exceptions/LoggingException.php | 13 ------------- src/LogLib/Handlers/ConsoleLogging.php | 5 ++--- src/LogLib/Handlers/FileLogging.php | 5 ++--- src/LogLib/Log.php | 12 +++--------- src/LogLib/Logger.php | 7 ------- 6 files changed, 8 insertions(+), 35 deletions(-) delete mode 100644 src/LogLib/Exceptions/LoggingException.php diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index a854623..935023b 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -25,5 +25,6 @@ + \ No newline at end of file diff --git a/src/LogLib/Exceptions/LoggingException.php b/src/LogLib/Exceptions/LoggingException.php deleted file mode 100644 index ad0bf19..0000000 --- a/src/LogLib/Exceptions/LoggingException.php +++ /dev/null @@ -1,13 +0,0 @@ -getCode(), $e); + throw new RuntimeException(sprintf('Unable to generate random color for application "%s"', $application_name), $e->getCode(), $e); } self::$application_colors[$application_name] = $color; diff --git a/src/LogLib/Handlers/FileLogging.php b/src/LogLib/Handlers/FileLogging.php index 661410e..dce2174 100644 --- a/src/LogLib/Handlers/FileLogging.php +++ b/src/LogLib/Handlers/FileLogging.php @@ -6,10 +6,10 @@ use LogLib\Classes\FileLock; use LogLib\Classes\Utilities; use LogLib\Classes\Validate; use LogLib\Enums\LogLevel; -use LogLib\Exceptions\LoggingException; use LogLib\Interfaces\LogHandlerInterface; use LogLib\Objects\Application; use LogLib\Objects\Event; +use RuntimeException; use Throwable; class FileLogging implements LogHandlerInterface @@ -80,7 +80,6 @@ class FileLogging implements LogHandlerInterface * * @param Application $application The application instance for which the log file is to be retrieved. * @return string The full path of the log file. - * @throws LoggingException If the logging directory is not writable or cannot be created. */ private static function getLogFile(Application $application): string { @@ -88,7 +87,7 @@ class FileLogging implements LogHandlerInterface if(!is_writable($logging_directory)) { - throw new LoggingException(sprintf("Cannot write to %s due to insufficient permissions", $logging_directory)); + throw new RuntimeException(sprintf("Cannot write to %s due to insufficient permissions", $logging_directory)); } if(!file_exists($logging_directory)) diff --git a/src/LogLib/Log.php b/src/LogLib/Log.php index 17cd913..d39db82 100644 --- a/src/LogLib/Log.php +++ b/src/LogLib/Log.php @@ -4,10 +4,10 @@ namespace LogLib; + use Exception; use InvalidArgumentException; use LogLib\Classes\Utilities; use LogLib\Enums\LogLevel; - use LogLib\Exceptions\LoggingException; use LogLib\Objects\Application; use LogLib\Objects\Event; use Throwable; @@ -23,6 +23,7 @@ * Registers a new application logger * * @param Application $application The options for the application + * @param bool $overwrite * @return bool */ public static function register(Application $application, bool $overwrite=false): bool @@ -107,7 +108,6 @@ * @param string|null $message The message of the log event * @param Throwable|null $throwable The exception that was thrown, if any * @return void - * @throws LoggingException */ private static function log(?string $application_name, LogLevel $level=LogLevel::INFO, ?string $message=null, ?Throwable $throwable=null): void { @@ -140,7 +140,6 @@ * @param string $application_name The name of the application * @param string $message The message of the event * @return void - * @throws LoggingException */ public static function info(string $application_name, string $message): void { @@ -151,7 +150,6 @@ * @param string $application_name The name of the application * @param string $message The message of the event * @return void - * @throws LoggingException */ public static function verbose(string $application_name, string $message): void { @@ -162,7 +160,6 @@ * @param string $application_name The name of the application * @param string $message The message of the event * @return void - * @throws LoggingException */ public static function debug(string $application_name, string $message): void { @@ -176,7 +173,6 @@ * @param string $message The warning message to log. * @param Throwable|null $throwable (Optional) The throwable object associated with the warning. * @return void - * @throws LoggingException */ public static function warning(string $application_name, string $message, ?Throwable $throwable=null): void { @@ -190,7 +186,6 @@ * @param string $message The error message. * @param Throwable|null $throwable The optional throwable object associated with the error. * @return void - * @throws LoggingException */ public static function error(string $application_name, string $message, ?Throwable $throwable=null): void { @@ -204,7 +199,6 @@ * @param string $message The fatal message to log. * @param Throwable|null $throwable (Optional) The throwable object associated with the fatal message. * @return void - * @throws LoggingException */ public static function fatal(string $application_name, string $message, ?Throwable $throwable=null): void { @@ -224,7 +218,7 @@ { self::error('Runtime', $throwable->getMessage(), $throwable); } - catch(LoggingException) + catch(Exception) { return; } diff --git a/src/LogLib/Logger.php b/src/LogLib/Logger.php index 5af777e..7cec8ab 100644 --- a/src/LogLib/Logger.php +++ b/src/LogLib/Logger.php @@ -2,7 +2,6 @@ namespace LogLib; -use LogLib\Exceptions\LoggingException; use LogLib\Objects\Application; use Throwable; @@ -22,7 +21,6 @@ class Logger extends Application * * @param string $message The message to log. * @return void - * @throws LoggingException */ public function info(string $message): void { @@ -34,7 +32,6 @@ class Logger extends Application * * @param string $message The message to be logged. * @return void - * @throws LoggingException */ public function verbose(string $message): void { @@ -46,7 +43,6 @@ class Logger extends Application * * @param string $message The debug message to log. * @return void - * @throws LoggingException */ public function debug(string $message): void { @@ -58,7 +54,6 @@ class Logger extends Application * * @param string $message The warning message to log. * @return void - * @throws LoggingException */ public function warning(string $message): void { @@ -71,7 +66,6 @@ class Logger extends Application * @param string $message The error message to be logged. * @param Throwable|null $throwable An optional throwable instance to be logged along with the error message. * @return void - * @throws LoggingException */ public function error(string $message, ?Throwable $throwable=null): void { @@ -84,7 +78,6 @@ class Logger extends Application * @param string $message The fatal error message to log. * @param Throwable|null $throwable Optional throwable associated with the fatal error. * @return void - * @throws LoggingException */ public function fatal(string $message, ?Throwable $throwable=null): void {