Removed unused LoggingException

This commit is contained in:
netkas 2024-10-28 19:47:20 -04:00
parent 7e779ab41b
commit 735dc7b33e
6 changed files with 8 additions and 35 deletions

View file

@ -25,5 +25,6 @@
</set>
</option>
</inspection_tool>
<inspection_tool class="PhpDocRedundantThrowsInspection" enabled="true" level="INFORMATION" enabled_by_default="true" />
</profile>
</component>

View file

@ -1,13 +0,0 @@
<?php
namespace LogLib\Exceptions;
use Exception;
class LoggingException extends Exception
{
public function __construct(string $message='', int $code=0, Exception $previous=null)
{
parent::__construct($message, $code, $previous);
}
}

View file

@ -7,10 +7,10 @@ use LogLib\Classes\Utilities;
use LogLib\Classes\Validate;
use LogLib\Enums\ConsoleColors;
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 ConsoleLogging implements LogHandlerInterface
@ -77,7 +77,6 @@ class ConsoleLogging implements LogHandlerInterface
*
* @param string $application_name The application name
* @return string The formatted application name
* @throws LoggingException If unable to generate a random color for the application
*/
private static function formatAppColor(string $application_name): string
{
@ -91,7 +90,7 @@ class ConsoleLogging implements LogHandlerInterface
}
catch (Exception $e)
{
throw new LoggingException(sprintf('Unable to generate random color for application "%s"', $application_name), $e->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;

View file

@ -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))

View file

@ -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;
}

View file

@ -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
{