Add LogHandlerInterface and related types

This commit is contained in:
netkas 2024-10-28 15:29:46 -04:00
parent 9d0dbad846
commit dec96d85e1
3 changed files with 51 additions and 0 deletions

View file

@ -0,0 +1,9 @@
<?php
namespace LogLib\Enums;
enum LogHandlerType : string
{
case CONSOLE = 'console';
case FILE = 'file';
}

View 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);
}
}

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