mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-13 15:18:41 +00:00
Minor fixes
Allowing verbose debugging and minimizing function overhead
This commit is contained in:
parent
09ca1a5c08
commit
bb31881f59
|
|
@ -55,6 +55,14 @@ class FileLogger implements LoggerInterface
|
||||||
*/
|
*/
|
||||||
protected static $instance = null;
|
protected static $instance = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verbose.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
protected static $verbose = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The file pointer for the logging.
|
* The file pointer for the logging.
|
||||||
*
|
*
|
||||||
|
|
@ -79,13 +87,15 @@ class FileLogger implements LoggerInterface
|
||||||
* Creates the logging object and overwrites all default values.
|
* Creates the logging object and overwrites all default values.
|
||||||
*
|
*
|
||||||
* @param string $lpath Path for logging
|
* @param string $lpath Path for logging
|
||||||
|
* @param bool $verbose Verbose logging
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
* @author Dennis Eichhorn
|
* @author Dennis Eichhorn
|
||||||
*/
|
*/
|
||||||
public function __construct(string $lpath)
|
public function __construct(string $lpath, bool $verbose = false)
|
||||||
{
|
{
|
||||||
$path = realpath($lpath);
|
$path = realpath($lpath);
|
||||||
|
self::$verbose = $verbose;
|
||||||
|
|
||||||
if ($path !== false && Validator::startsWith($path, ROOT_PATH) === false) {
|
if ($path !== false && Validator::startsWith($path, ROOT_PATH) === false) {
|
||||||
throw new PathException($lpath);
|
throw new PathException($lpath);
|
||||||
|
|
@ -286,6 +296,10 @@ class FileLogger implements LoggerInterface
|
||||||
$this->fp = fopen($this->path, 'a');
|
$this->fp = fopen($this->path, 'a');
|
||||||
fwrite($this->fp, $message . "\n");
|
fwrite($this->fp, $message . "\n");
|
||||||
fclose($this->fp);
|
fclose($this->fp);
|
||||||
|
|
||||||
|
if(self::$verbose) {
|
||||||
|
echo $message . "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -102,12 +102,10 @@ class UriFactory
|
||||||
*/
|
*/
|
||||||
public static function build(string $uri, array $toMatch = [])
|
public static function build(string $uri, array $toMatch = [])
|
||||||
{
|
{
|
||||||
$uri = preg_replace_callback('(\{[\/#\?@\.\$][a-zA-Z0-9]*\})', function ($match) use ($toMatch) {
|
return preg_replace_callback('(\{[\/#\?@\.\$][a-zA-Z0-9]*\})', function ($match) use ($toMatch) {
|
||||||
$match = substr($match[0], 1, strlen($match[0]) - 2);
|
$match = substr($match[0], 1, strlen($match[0]) - 2);
|
||||||
|
|
||||||
return $toMatch[$match] ?? self::$uri[$match] ?? $match;
|
return $toMatch[$match] ?? self::$uri[$match] ?? $match;
|
||||||
}, $uri);
|
}, $uri);
|
||||||
|
|
||||||
return $uri;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user