Add LogHandlerInterface and related types
This commit is contained in:
parent
9d0dbad846
commit
dec96d85e1
3 changed files with 51 additions and 0 deletions
9
src/LogLib/Enums/LogHandlerType.php
Normal file
9
src/LogLib/Enums/LogHandlerType.php
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace LogLib\Enums;
|
||||||
|
|
||||||
|
enum LogHandlerType : string
|
||||||
|
{
|
||||||
|
case CONSOLE = 'console';
|
||||||
|
case FILE = 'file';
|
||||||
|
}
|
13
src/LogLib/Exceptions/LoggingException.php
Normal file
13
src/LogLib/Exceptions/LoggingException.php
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?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);
|
||||||
|
}
|
||||||
|
}
|
29
src/LogLib/Interfaces/LogHandlerInterface.php
Normal file
29
src/LogLib/Interfaces/LogHandlerInterface.php
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace LogLib\Interfaces;
|
||||||
|
|
||||||
|
use LogLib\Enums\LogHandlerType;
|
||||||
|
use LogLib\Exceptions\LoggingException;
|
||||||
|
use LogLib\Objects\Application;
|
||||||
|
use LogLib\Objects\Event;
|
||||||
|
use LogLib\Objects\Options;
|
||||||
|
|
||||||
|
interface LogHandlerInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Outputs the event details based on the given options.
|
||||||
|
*
|
||||||
|
* @param Application $application The options used to configure the output
|
||||||
|
* @param Event $event The event to be output
|
||||||
|
* @return void
|
||||||
|
* @throws LoggingException If an error occurs while handling the event
|
||||||
|
*/
|
||||||
|
public static function handle(Application $application, Event $event): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the type of log handler.
|
||||||
|
*
|
||||||
|
* @return LogHandlerType
|
||||||
|
*/
|
||||||
|
public static function getType(): LogHandlerType;
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue