"Refactor logging logic to improve log level and backtrace information
The code has been updated to enhance the way log levels and backtrace information is handled. Changes have been done to ensure the backtrace ignores any calls coming from the LogLib namespace, improving clarity and reducing noise in the log output. Additionally, changes were made to 'colorize' and 'log' methods to adjust the typing of the log level from string to integer, enhancing the consistency of log level usage throughout the code. Removed the Backtrace class that was not serving any purpose after these updates. Tests are also updated to ensure proper functionality."
This commit is contained in:
parent
7f2332e228
commit
3097bcbc87
7 changed files with 157 additions and 228 deletions
|
@ -31,4 +31,11 @@
|
||||||
* @var string LAMBDA_CALL
|
* @var string LAMBDA_CALL
|
||||||
*/
|
*/
|
||||||
public const LAMBDA_CALL = 'λ';
|
public const LAMBDA_CALL = 'λ';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an eval() call.
|
||||||
|
*
|
||||||
|
* @var string EVAL_CALL
|
||||||
|
*/
|
||||||
|
public const EVAL_CALL = 'eval()';
|
||||||
}
|
}
|
|
@ -82,17 +82,16 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies a specified color to the given text, based on the event level, using ANSI escape sequences.
|
* Colorizes the log message based on the event level using ANSI escape sequences.
|
||||||
*
|
*
|
||||||
* @param Event $event The event object.
|
* @param Event $event The log event to colorize.
|
||||||
* @param string $text The text to apply the color to.
|
* @return string The colorized log message.
|
||||||
* @return string The text with the specified color applied.
|
|
||||||
*/
|
*/
|
||||||
private static function colorize(Event $event, string $text): string
|
private static function colorize(Event $event): string
|
||||||
{
|
{
|
||||||
if(!Log::getRuntimeOptions()->displayAnsi())
|
if(!Log::getRuntimeOptions()->displayAnsi())
|
||||||
{
|
{
|
||||||
return Utilities::levelToString($text);
|
return Utilities::levelToString($event->getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
$color = match($event->getLevel())
|
$color = match($event->getLevel())
|
||||||
|
@ -108,10 +107,10 @@
|
||||||
|
|
||||||
if($color === null)
|
if($color === null)
|
||||||
{
|
{
|
||||||
return Utilities::levelToString($text);
|
return Utilities::levelToString($event->getLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::color(Utilities::levelToString($text), $color);
|
return self::color(Utilities::levelToString($event->getLevel()), $color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,30 +165,46 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Validate::checkLevelType(LevelType::VERBOSE, Log::getRuntimeOptions()->getLoglevel()))
|
if(Validate::checkLevelType(LevelType::DEBUG, Log::getRuntimeOptions()->getLoglevel()))
|
||||||
{
|
{
|
||||||
$backtrace_output = Utilities::getTraceString($event, Log::getRuntimeOptions()->displayAnsi());
|
$backtrace_output = Utilities::getTraceString($event, Log::getRuntimeOptions()->displayAnsi());
|
||||||
|
|
||||||
print(sprintf("[%s] [%s] [%s] %s %s" . PHP_EOL,
|
print(sprintf("[%s] [%s] [%s] %s %s" . PHP_EOL,
|
||||||
self::getTimestamp(),
|
self::getTimestamp(),
|
||||||
self::formatAppColor($options->getApplicationName()),
|
self::formatAppColor($options->getApplicationName()),
|
||||||
self::colorize($event, $event->getLevel()),
|
self::colorize($event),
|
||||||
$backtrace_output, $event->getMessage()
|
$backtrace_output, $event->getMessage()
|
||||||
));
|
));
|
||||||
|
|
||||||
if($event->getException() !== null)
|
if($event->getException() !== null)
|
||||||
{
|
{
|
||||||
/** @noinspection NullPointerExceptionInspection */
|
|
||||||
self::outException($event->getException());
|
self::outException($event->getException());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
print(sprintf("[%s] [%s] [%s] %s" . PHP_EOL,
|
if(Validate::checkLevelType(LevelType::VERBOSE, Log::getRuntimeOptions()->getLoglevel()))
|
||||||
self::getTimestamp(),
|
{
|
||||||
|
$backtrace_output = Utilities::getTraceString($event, Log::getRuntimeOptions()->displayAnsi());
|
||||||
|
|
||||||
|
print(sprintf("[%s] [%s] %s %s" . PHP_EOL,
|
||||||
self::formatAppColor($options->getApplicationName()),
|
self::formatAppColor($options->getApplicationName()),
|
||||||
self::colorize($event, $event->getLevel()),
|
self::colorize($event),
|
||||||
|
$backtrace_output, $event->getMessage()
|
||||||
|
));
|
||||||
|
|
||||||
|
if($event->getException() !== null)
|
||||||
|
{
|
||||||
|
self::outException($event->getException());
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
print(sprintf("[%s] [%s] %s" . PHP_EOL,
|
||||||
|
self::formatAppColor($options->getApplicationName()),
|
||||||
|
self::colorize($event),
|
||||||
$event->getMessage()
|
$event->getMessage()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -198,11 +213,16 @@
|
||||||
* Prints information about the given exception, including the error message, error code,
|
* Prints information about the given exception, including the error message, error code,
|
||||||
* and stack trace.
|
* and stack trace.
|
||||||
*
|
*
|
||||||
* @param Throwable $exception The exception to print information about.
|
* @param Throwable|null $exception The exception to print information about.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function outException(Throwable $exception): void
|
private static function outException(?Throwable $exception=null): void
|
||||||
{
|
{
|
||||||
|
if($exception === null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$trace_header = self::color($exception->getFile() . ':' . $exception->getLine(), ConsoleColors::PURPLE);
|
$trace_header = self::color($exception->getFile() . ':' . $exception->getLine(), ConsoleColors::PURPLE);
|
||||||
$trace_error = self::color('error: ', ConsoleColors::RED);
|
$trace_error = self::color('error: ', ConsoleColors::RED);
|
||||||
|
|
||||||
|
@ -223,7 +243,6 @@
|
||||||
{
|
{
|
||||||
print('Previous Exception:' . PHP_EOL);
|
print('Previous Exception:' . PHP_EOL);
|
||||||
|
|
||||||
/** @noinspection NullPointerExceptionInspection */
|
|
||||||
self::outException($exception->getPrevious());
|
self::outException($exception->getPrevious());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
use LogLib\Abstracts\CallType;
|
use LogLib\Abstracts\CallType;
|
||||||
use LogLib\Abstracts\LevelType;
|
use LogLib\Abstracts\LevelType;
|
||||||
use LogLib\Objects\Backtrace;
|
|
||||||
use LogLib\Objects\Event;
|
use LogLib\Objects\Event;
|
||||||
use OptsLib\Parse;
|
use OptsLib\Parse;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
@ -14,36 +13,23 @@
|
||||||
/**
|
/**
|
||||||
* Returns a backtrace of the calling code.
|
* Returns a backtrace of the calling code.
|
||||||
*
|
*
|
||||||
* @param bool $full Determines whether the full backtrace should be returned or not. Default is false.
|
|
||||||
* @return array An array containing backtrace information.
|
* @return array An array containing backtrace information.
|
||||||
* Each element in the array represents a single call in the call stack and is an instance of the Backtrace class.
|
|
||||||
* If the debug_backtrace () function is not available, an empty array will be returned.
|
|
||||||
*/
|
*/
|
||||||
public static function getBacktrace(bool $full=false): array
|
public static function getBacktrace(): array
|
||||||
{
|
{
|
||||||
if(!function_exists('debug_backtrace'))
|
if(!function_exists('debug_backtrace'))
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$backtrace = debug_backtrace();
|
return debug_backtrace();
|
||||||
$results = [];
|
|
||||||
|
|
||||||
foreach($backtrace as $trace)
|
|
||||||
{
|
|
||||||
if(!$full && isset($trace['class']) && str_contains($trace['class'], 'LogLib'))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$results[] = new Backtrace($trace);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Converts a log level to its corresponding string representation.
|
||||||
*
|
*
|
||||||
|
* @param int $level The log level to convert.
|
||||||
|
* @return string The string representation of the log level.
|
||||||
*/
|
*/
|
||||||
public static function levelToString(int $level): string
|
public static function levelToString(int $level): string
|
||||||
{
|
{
|
||||||
|
@ -176,19 +162,58 @@
|
||||||
*/
|
*/
|
||||||
public static function getTraceString(Event $event, bool $ansi=false): ?string
|
public static function getTraceString(Event $event, bool $ansi=false): ?string
|
||||||
{
|
{
|
||||||
if($event->getBacktrace() === null)
|
if($event->getBacktrace() === null || count($event->getBacktrace()) === 0)
|
||||||
{
|
{
|
||||||
return CallType::LAMBDA_CALL;
|
return CallType::LAMBDA_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$backtrace = $event->getBacktrace()[0];
|
$backtrace = $event->getBacktrace()[count($event->getBacktrace()) - 1];
|
||||||
$function = $backtrace->getFunction();
|
|
||||||
$class = $backtrace->getClass();
|
// Ignore \LogLib namespace
|
||||||
|
if(isset($backtrace['class']) && str_starts_with($backtrace['class'], 'LogLib'))
|
||||||
|
{
|
||||||
|
if(isset($backtrace['file']))
|
||||||
|
{
|
||||||
|
return ($ansi ? "\033[1;37m" : '') . basename($backtrace['file']) . ($ansi ? "\033[0m" : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
return basename($backtrace['file']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($backtrace['function'] === '{closure}')
|
||||||
|
{
|
||||||
|
if(isset($backtrace['file']))
|
||||||
|
{
|
||||||
|
return ($ansi ? "\033[1;37m" : '') . basename($backtrace['file']) . ($ansi ? "\033[0m" : '') . CallType::STATIC_CALL . CallType::LAMBDA_CALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return basename($backtrace['file']) . CallType::STATIC_CALL . CallType::LAMBDA_CALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($backtrace['function'] === 'eval')
|
||||||
|
{
|
||||||
|
if(isset($backtrace['file']))
|
||||||
|
{
|
||||||
|
return ($ansi ? "\033[1;37m" : '') . basename($backtrace['file']) . ($ansi ? "\033[0m" : '') . CallType::STATIC_CALL . CallType::EVAL_CALL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return basename($backtrace['file']) . CallType::STATIC_CALL . CallType::EVAL_CALL;
|
||||||
|
}
|
||||||
|
|
||||||
if($ansi)
|
if($ansi)
|
||||||
{
|
{
|
||||||
$function = "\033[1;37m$function\033[0m";
|
$function = sprintf("\033[1;37m%s\033[0m", $backtrace['function']);
|
||||||
$class = "\033[1;37m$class\033[0m";
|
$class = null;
|
||||||
|
|
||||||
|
if(isset($backtrace["class"]))
|
||||||
|
{
|
||||||
|
$class = sprintf("\033[1;37m%s\033[0m", $backtrace['class']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$function = $backtrace['function'];
|
||||||
|
$class = $backtrace['class'] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($class === null)
|
if($class === null)
|
||||||
|
@ -196,10 +221,11 @@
|
||||||
return $function . CallType::FUNCTION_CALL;
|
return $function . CallType::FUNCTION_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$type = ($backtrace->getType() === CallType::METHOD_CALL ? CallType::METHOD_CALL : CallType::STATIC_CALL);
|
$type = ($backtrace['type'] === CallType::METHOD_CALL ? CallType::METHOD_CALL : CallType::STATIC_CALL);
|
||||||
return "{$class}{$type}{$function}" . CallType::FUNCTION_CALL;
|
return "{$class}{$type}{$function}" . CallType::FUNCTION_CALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an exception object to an array representation.
|
* Converts an exception object to an array representation.
|
||||||
*
|
*
|
||||||
|
|
|
@ -110,13 +110,13 @@
|
||||||
* Logs a message with a specified application name, level, optional message, and optional throwable.
|
* Logs a message with a specified application name, level, optional message, and optional throwable.
|
||||||
*
|
*
|
||||||
* @param string $application_name The name of the application
|
* @param string $application_name The name of the application
|
||||||
* @param string $level The level type of the log (default is LevelType::INFO)
|
* @param int $level The level type of the log (default is LevelType::INFO)
|
||||||
* @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 InvalidArgumentException If the provided level type is invalid or a message is null
|
* @throws InvalidArgumentException If the provided level type is invalid or a message is null
|
||||||
*/
|
*/
|
||||||
private static function log(string $application_name, string $level=LevelType::INFO, ?string $message=null, ?Throwable $throwable=null): void
|
private static function log(string $application_name, int $level=LevelType::INFO, ?string $message=null, ?Throwable $throwable=null): void
|
||||||
{
|
{
|
||||||
$application = self::getOptions($application_name);
|
$application = self::getOptions($application_name);
|
||||||
|
|
||||||
|
|
|
@ -1,179 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/** @noinspection PhpMissingFieldTypeInspection */
|
|
||||||
|
|
||||||
namespace LogLib\Objects;
|
|
||||||
|
|
||||||
class Backtrace
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
private $function;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int|null
|
|
||||||
*/
|
|
||||||
private $line;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
private $file;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
private $class;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see CallType
|
|
||||||
* @var string|null
|
|
||||||
*/
|
|
||||||
private $type;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array|null
|
|
||||||
*/
|
|
||||||
private $args;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Public Constructor
|
|
||||||
*
|
|
||||||
* @param array|null $backtrace
|
|
||||||
*/
|
|
||||||
public function __construct(?array $backtrace=null)
|
|
||||||
{
|
|
||||||
if($backtrace === null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->function = $backtrace['function'] ?? null;
|
|
||||||
$this->line = $backtrace['line'] ?? null;
|
|
||||||
$this->file = $backtrace['file'] ?? null;
|
|
||||||
$this->class = $backtrace['class'] ?? null;
|
|
||||||
$this->type = $backtrace['type'] ?? null;
|
|
||||||
$this->args = $backtrace['args'] ?? null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional. Returns the function name of the backtrace
|
|
||||||
*
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
public function getFunction(): ?string
|
|
||||||
{
|
|
||||||
return $this->function;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the function name of the backtrace
|
|
||||||
*
|
|
||||||
* @param string|null $function
|
|
||||||
*/
|
|
||||||
public function setFunction(?string $function): void
|
|
||||||
{
|
|
||||||
$this->function = $function;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional. Returns the line number of the backtrace
|
|
||||||
*
|
|
||||||
* @return int|null
|
|
||||||
*/
|
|
||||||
public function getLine(): ?int
|
|
||||||
{
|
|
||||||
return $this->line;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the line number of the backtrace
|
|
||||||
*
|
|
||||||
* @param int|null $line
|
|
||||||
*/
|
|
||||||
public function setLine(?int $line): void
|
|
||||||
{
|
|
||||||
$this->line = $line;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional. Returns the file name of the backtrace
|
|
||||||
*
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
public function getFile(): ?string
|
|
||||||
{
|
|
||||||
return $this->file;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the file name of the backtrace
|
|
||||||
*
|
|
||||||
* @param string|null $file
|
|
||||||
*/
|
|
||||||
public function setFile(?string $file): void
|
|
||||||
{
|
|
||||||
$this->file = $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional. Returns the class name, if any, of the backtrace
|
|
||||||
*
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
public function getClass(): ?string
|
|
||||||
{
|
|
||||||
return $this->class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the class name, if any, of the backtrace
|
|
||||||
*
|
|
||||||
* @param string|null $class
|
|
||||||
*/
|
|
||||||
public function setClass(?string $class): void
|
|
||||||
{
|
|
||||||
$this->class = $class;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional. Returns the current call type. If a method call, "->" is returned.
|
|
||||||
*
|
|
||||||
* @return string|null
|
|
||||||
*/
|
|
||||||
public function getType(): ?string
|
|
||||||
{
|
|
||||||
return $this->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the current call type. If a method call, "->" is returned.
|
|
||||||
*
|
|
||||||
* @param string|null $type
|
|
||||||
*/
|
|
||||||
public function setType(?string $type): void
|
|
||||||
{
|
|
||||||
$this->type = $type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional. Return the functions arguments or included file name(s)
|
|
||||||
*
|
|
||||||
* @return array|null
|
|
||||||
*/
|
|
||||||
public function getArgs(): ?array
|
|
||||||
{
|
|
||||||
return $this->args;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the function arguments or included file name(s)
|
|
||||||
*
|
|
||||||
* @param array|null $args
|
|
||||||
*/
|
|
||||||
public function setArgs(?array $args): void
|
|
||||||
{
|
|
||||||
$this->args = $args;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -12,12 +12,12 @@
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @see LevelType
|
* @see LevelType
|
||||||
* @var string
|
* @var int
|
||||||
*/
|
*/
|
||||||
private $level;
|
private $level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Backtrace[]|null
|
* @var array|null
|
||||||
*/
|
*/
|
||||||
private $backtrace;
|
private $backtrace;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use LogLib\Abstracts\LevelType;
|
|
||||||
use LogLib\Log;
|
use LogLib\Log;
|
||||||
use LogLib\Objects\Options;
|
use LogLib\Objects\Options;
|
||||||
|
|
||||||
|
@ -16,3 +15,60 @@
|
||||||
Log::warning('net.nosial.optslib', 'This is a warning message');
|
Log::warning('net.nosial.optslib', 'This is a warning message');
|
||||||
Log::error('net.nosial.optslib', 'This is an error message');
|
Log::error('net.nosial.optslib', 'This is an error message');
|
||||||
Log::fatal('net.nosial.optslib', 'This is a fatal message');
|
Log::fatal('net.nosial.optslib', 'This is a fatal message');
|
||||||
|
|
||||||
|
|
||||||
|
class test
|
||||||
|
{
|
||||||
|
public function testLogging(): void
|
||||||
|
{
|
||||||
|
Log::debug('net.nosial.optslib', 'This is a debug message');
|
||||||
|
Log::verbose('net.nosial.optslib', 'This is a verbose message');
|
||||||
|
Log::info('net.nosial.optslib', 'This is an info message');
|
||||||
|
Log::warning('net.nosial.optslib', 'This is a warning message');
|
||||||
|
Log::error('net.nosial.optslib', 'This is an error message');
|
||||||
|
Log::fatal('net.nosial.optslib', 'This is a fatal message');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$test = new test();
|
||||||
|
$test->testLogging();
|
||||||
|
|
||||||
|
eval('\LogLib\Log::debug(\'net.nosial.optslib\', \'This is a debug message\');');
|
||||||
|
eval('\LogLib\Log::verbose(\'net.nosial.optslib\', \'This is a verbose message\');');
|
||||||
|
|
||||||
|
$callable = static function()
|
||||||
|
{
|
||||||
|
Log::info('net.nosial.optslib', 'This is an info message');
|
||||||
|
Log::warning('net.nosial.optslib', 'This is a warning message');
|
||||||
|
Log::error('net.nosial.optslib', 'This is an error message');
|
||||||
|
Log::fatal('net.nosial.optslib', 'This is a fatal message');
|
||||||
|
};
|
||||||
|
|
||||||
|
$callable();
|
||||||
|
|
||||||
|
|
||||||
|
class test2
|
||||||
|
{
|
||||||
|
public function testEval(): void
|
||||||
|
{
|
||||||
|
eval('\LogLib\Log::debug(\'net.nosial.optslib\', \'This is a debug message\');');
|
||||||
|
eval('\LogLib\Log::verbose(\'net.nosial.optslib\', \'This is a verbose message\');');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCallable(): void
|
||||||
|
{
|
||||||
|
$b = static function()
|
||||||
|
{
|
||||||
|
Log::info('net.nosial.optslib', 'This is an info message');
|
||||||
|
Log::warning('net.nosial.optslib', 'This is a warning message');
|
||||||
|
Log::error('net.nosial.optslib', 'This is an error message');
|
||||||
|
Log::fatal('net.nosial.optslib', 'This is a fatal message');
|
||||||
|
};
|
||||||
|
|
||||||
|
$b();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$test2 = new test2();
|
||||||
|
$test2->testEval();
|
||||||
|
$test2->testCallable();
|
Loading…
Add table
Reference in a new issue