Removed unused LoggingException
This commit is contained in:
parent
7e779ab41b
commit
735dc7b33e
6 changed files with 8 additions and 35 deletions
1
.idea/inspectionProfiles/Project_Default.xml
generated
1
.idea/inspectionProfiles/Project_Default.xml
generated
|
@ -25,5 +25,6 @@
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
</inspection_tool>
|
</inspection_tool>
|
||||||
|
<inspection_tool class="PhpDocRedundantThrowsInspection" enabled="true" level="INFORMATION" enabled_by_default="true" />
|
||||||
</profile>
|
</profile>
|
||||||
</component>
|
</component>
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,10 +7,10 @@ use LogLib\Classes\Utilities;
|
||||||
use LogLib\Classes\Validate;
|
use LogLib\Classes\Validate;
|
||||||
use LogLib\Enums\ConsoleColors;
|
use LogLib\Enums\ConsoleColors;
|
||||||
use LogLib\Enums\LogLevel;
|
use LogLib\Enums\LogLevel;
|
||||||
use LogLib\Exceptions\LoggingException;
|
|
||||||
use LogLib\Interfaces\LogHandlerInterface;
|
use LogLib\Interfaces\LogHandlerInterface;
|
||||||
use LogLib\Objects\Application;
|
use LogLib\Objects\Application;
|
||||||
use LogLib\Objects\Event;
|
use LogLib\Objects\Event;
|
||||||
|
use RuntimeException;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class ConsoleLogging implements LogHandlerInterface
|
class ConsoleLogging implements LogHandlerInterface
|
||||||
|
@ -77,7 +77,6 @@ class ConsoleLogging implements LogHandlerInterface
|
||||||
*
|
*
|
||||||
* @param string $application_name The application name
|
* @param string $application_name The application name
|
||||||
* @return string The formatted 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
|
private static function formatAppColor(string $application_name): string
|
||||||
{
|
{
|
||||||
|
@ -91,7 +90,7 @@ class ConsoleLogging implements LogHandlerInterface
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
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;
|
self::$application_colors[$application_name] = $color;
|
||||||
|
|
|
@ -6,10 +6,10 @@ use LogLib\Classes\FileLock;
|
||||||
use LogLib\Classes\Utilities;
|
use LogLib\Classes\Utilities;
|
||||||
use LogLib\Classes\Validate;
|
use LogLib\Classes\Validate;
|
||||||
use LogLib\Enums\LogLevel;
|
use LogLib\Enums\LogLevel;
|
||||||
use LogLib\Exceptions\LoggingException;
|
|
||||||
use LogLib\Interfaces\LogHandlerInterface;
|
use LogLib\Interfaces\LogHandlerInterface;
|
||||||
use LogLib\Objects\Application;
|
use LogLib\Objects\Application;
|
||||||
use LogLib\Objects\Event;
|
use LogLib\Objects\Event;
|
||||||
|
use RuntimeException;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class FileLogging implements LogHandlerInterface
|
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.
|
* @param Application $application The application instance for which the log file is to be retrieved.
|
||||||
* @return string The full path of the log file.
|
* @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
|
private static function getLogFile(Application $application): string
|
||||||
{
|
{
|
||||||
|
@ -88,7 +87,7 @@ class FileLogging implements LogHandlerInterface
|
||||||
|
|
||||||
if(!is_writable($logging_directory))
|
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))
|
if(!file_exists($logging_directory))
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
namespace LogLib;
|
namespace LogLib;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use LogLib\Classes\Utilities;
|
use LogLib\Classes\Utilities;
|
||||||
use LogLib\Enums\LogLevel;
|
use LogLib\Enums\LogLevel;
|
||||||
use LogLib\Exceptions\LoggingException;
|
|
||||||
use LogLib\Objects\Application;
|
use LogLib\Objects\Application;
|
||||||
use LogLib\Objects\Event;
|
use LogLib\Objects\Event;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
@ -23,6 +23,7 @@
|
||||||
* Registers a new application logger
|
* Registers a new application logger
|
||||||
*
|
*
|
||||||
* @param Application $application The options for the application
|
* @param Application $application The options for the application
|
||||||
|
* @param bool $overwrite
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function register(Application $application, bool $overwrite=false): 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 string|null $message The message of the log event
|
||||||
* @param Throwable|null $throwable The exception that was thrown, if any
|
* @param Throwable|null $throwable The exception that was thrown, if any
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
private static function log(?string $application_name, LogLevel $level=LogLevel::INFO, ?string $message=null, ?Throwable $throwable=null): void
|
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 $application_name The name of the application
|
||||||
* @param string $message The message of the event
|
* @param string $message The message of the event
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
public static function info(string $application_name, string $message): void
|
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 $application_name The name of the application
|
||||||
* @param string $message The message of the event
|
* @param string $message The message of the event
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
public static function verbose(string $application_name, string $message): void
|
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 $application_name The name of the application
|
||||||
* @param string $message The message of the event
|
* @param string $message The message of the event
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
public static function debug(string $application_name, string $message): void
|
public static function debug(string $application_name, string $message): void
|
||||||
{
|
{
|
||||||
|
@ -176,7 +173,6 @@
|
||||||
* @param string $message The warning message to log.
|
* @param string $message The warning message to log.
|
||||||
* @param Throwable|null $throwable (Optional) The throwable object associated with the warning.
|
* @param Throwable|null $throwable (Optional) The throwable object associated with the warning.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
public static function warning(string $application_name, string $message, ?Throwable $throwable=null): void
|
public static function warning(string $application_name, string $message, ?Throwable $throwable=null): void
|
||||||
{
|
{
|
||||||
|
@ -190,7 +186,6 @@
|
||||||
* @param string $message The error message.
|
* @param string $message The error message.
|
||||||
* @param Throwable|null $throwable The optional throwable object associated with the error.
|
* @param Throwable|null $throwable The optional throwable object associated with the error.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
public static function error(string $application_name, string $message, ?Throwable $throwable=null): void
|
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 string $message The fatal message to log.
|
||||||
* @param Throwable|null $throwable (Optional) The throwable object associated with the fatal message.
|
* @param Throwable|null $throwable (Optional) The throwable object associated with the fatal message.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
public static function fatal(string $application_name, string $message, ?Throwable $throwable=null): void
|
public static function fatal(string $application_name, string $message, ?Throwable $throwable=null): void
|
||||||
{
|
{
|
||||||
|
@ -224,7 +218,7 @@
|
||||||
{
|
{
|
||||||
self::error('Runtime', $throwable->getMessage(), $throwable);
|
self::error('Runtime', $throwable->getMessage(), $throwable);
|
||||||
}
|
}
|
||||||
catch(LoggingException)
|
catch(Exception)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace LogLib;
|
namespace LogLib;
|
||||||
|
|
||||||
use LogLib\Exceptions\LoggingException;
|
|
||||||
use LogLib\Objects\Application;
|
use LogLib\Objects\Application;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
|
@ -22,7 +21,6 @@ class Logger extends Application
|
||||||
*
|
*
|
||||||
* @param string $message The message to log.
|
* @param string $message The message to log.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
public function info(string $message): void
|
public function info(string $message): void
|
||||||
{
|
{
|
||||||
|
@ -34,7 +32,6 @@ class Logger extends Application
|
||||||
*
|
*
|
||||||
* @param string $message The message to be logged.
|
* @param string $message The message to be logged.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
public function verbose(string $message): void
|
public function verbose(string $message): void
|
||||||
{
|
{
|
||||||
|
@ -46,7 +43,6 @@ class Logger extends Application
|
||||||
*
|
*
|
||||||
* @param string $message The debug message to log.
|
* @param string $message The debug message to log.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
public function debug(string $message): void
|
public function debug(string $message): void
|
||||||
{
|
{
|
||||||
|
@ -58,7 +54,6 @@ class Logger extends Application
|
||||||
*
|
*
|
||||||
* @param string $message The warning message to log.
|
* @param string $message The warning message to log.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
public function warning(string $message): void
|
public function warning(string $message): void
|
||||||
{
|
{
|
||||||
|
@ -71,7 +66,6 @@ class Logger extends Application
|
||||||
* @param string $message The error message to be logged.
|
* @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.
|
* @param Throwable|null $throwable An optional throwable instance to be logged along with the error message.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
public function error(string $message, ?Throwable $throwable=null): void
|
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 string $message The fatal error message to log.
|
||||||
* @param Throwable|null $throwable Optional throwable associated with the fatal error.
|
* @param Throwable|null $throwable Optional throwable associated with the fatal error.
|
||||||
* @return void
|
* @return void
|
||||||
* @throws LoggingException
|
|
||||||
*/
|
*/
|
||||||
public function fatal(string $message, ?Throwable $throwable=null): void
|
public function fatal(string $message, ?Throwable $throwable=null): void
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue