Move Introspection to Logger package
This commit is contained in:
parent
f4ea74447e
commit
22663c4ae5
8 changed files with 18 additions and 15 deletions
|
@ -27,7 +27,7 @@ use Friendica\Core;
|
||||||
use Friendica\Core\Logger\Exception\LogLevelException;
|
use Friendica\Core\Logger\Exception\LogLevelException;
|
||||||
use Friendica\Database\Database;
|
use Friendica\Database\Database;
|
||||||
use Friendica\Util\FileSystem;
|
use Friendica\Util\FileSystem;
|
||||||
use Friendica\Util\Introspection;
|
use Friendica\Core\Logger\Util\Introspection;
|
||||||
use Friendica\Core\Logger\Type\Monolog\DevelopHandler;
|
use Friendica\Core\Logger\Type\Monolog\DevelopHandler;
|
||||||
use Friendica\Core\Logger\Type\Monolog\IntrospectionProcessor;
|
use Friendica\Core\Logger\Type\Monolog\IntrospectionProcessor;
|
||||||
use Friendica\Core\Logger\Type\ProfilerLogger;
|
use Friendica\Core\Logger\Type\ProfilerLogger;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
namespace Friendica\Core\Logger\Type;
|
namespace Friendica\Core\Logger\Type;
|
||||||
|
|
||||||
use Friendica\Core\Logger\Exception\LoggerException;
|
use Friendica\Core\Logger\Exception\LoggerException;
|
||||||
use Friendica\Util\Introspection;
|
use Friendica\Core\Logger\Util\Introspection;
|
||||||
use Friendica\Util\Strings;
|
use Friendica\Util\Strings;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Psr\Log\LogLevel;
|
use Psr\Log\LogLevel;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
namespace Friendica\Core\Logger\Type\Monolog;
|
namespace Friendica\Core\Logger\Type\Monolog;
|
||||||
|
|
||||||
use Friendica\Util\Introspection;
|
use Friendica\Core\Logger\Util\Introspection;
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Monolog\Processor\ProcessorInterface;
|
use Monolog\Processor\ProcessorInterface;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ use Friendica\Core\Logger\Exception\LoggerException;
|
||||||
use Friendica\Core\Logger\Exception\LogLevelException;
|
use Friendica\Core\Logger\Exception\LogLevelException;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\FileSystem;
|
use Friendica\Util\FileSystem;
|
||||||
use Friendica\Util\Introspection;
|
use Friendica\Core\Logger\Util\Introspection;
|
||||||
use Psr\Log\LogLevel;
|
use Psr\Log\LogLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Friendica\Core\Logger\Type;
|
||||||
|
|
||||||
use Friendica\Core\Logger\Exception\LoggerException;
|
use Friendica\Core\Logger\Exception\LoggerException;
|
||||||
use Friendica\Core\Logger\Exception\LogLevelException;
|
use Friendica\Core\Logger\Exception\LogLevelException;
|
||||||
use Friendica\Util\Introspection;
|
use Friendica\Core\Logger\Util\Introspection;
|
||||||
use Psr\Log\LogLevel;
|
use Psr\Log\LogLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,15 +19,17 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Friendica\Util;
|
namespace Friendica\Core\Logger\Util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Introspection information about the current call
|
* Get Introspection information about the current call
|
||||||
*/
|
*/
|
||||||
class Introspection
|
class Introspection
|
||||||
{
|
{
|
||||||
|
/** @var int */
|
||||||
private $skipStackFramesCount;
|
private $skipStackFramesCount;
|
||||||
|
|
||||||
|
/** @var string[] */
|
||||||
private $skipClassesPartials;
|
private $skipClassesPartials;
|
||||||
|
|
||||||
private $skipFunctions = [
|
private $skipFunctions = [
|
||||||
|
@ -36,10 +38,10 @@ class Introspection
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $skipClassesPartials An array of classes to skip during logging
|
* @param string[] $skipClassesPartials An array of classes to skip during logging
|
||||||
* @param int $skipStackFramesCount If the logger should use information from other hierarchy levels of the call
|
* @param int $skipStackFramesCount If the logger should use information from other hierarchy levels of the call
|
||||||
*/
|
*/
|
||||||
public function __construct($skipClassesPartials = array(), $skipStackFramesCount = 0)
|
public function __construct(array $skipClassesPartials = [], int $skipStackFramesCount = 0)
|
||||||
{
|
{
|
||||||
$this->skipClassesPartials = $skipClassesPartials;
|
$this->skipClassesPartials = $skipClassesPartials;
|
||||||
$this->skipStackFramesCount = $skipStackFramesCount;
|
$this->skipStackFramesCount = $skipStackFramesCount;
|
||||||
|
@ -47,6 +49,7 @@ class Introspection
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds new classes to get skipped
|
* Adds new classes to get skipped
|
||||||
|
*
|
||||||
* @param array $classNames
|
* @param array $classNames
|
||||||
*/
|
*/
|
||||||
public function addClasses(array $classNames)
|
public function addClasses(array $classNames)
|
||||||
|
@ -59,7 +62,7 @@ class Introspection
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getRecord()
|
public function getRecord(): array
|
||||||
{
|
{
|
||||||
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
|
|
||||||
|
@ -73,8 +76,8 @@ class Introspection
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'file' => isset($trace[$i - 1]['file']) ? basename($trace[$i - 1]['file']) : null,
|
'file' => isset($trace[$i - 1]['file']) ? basename($trace[$i - 1]['file']) : null,
|
||||||
'line' => isset($trace[$i - 1]['line']) ? $trace[$i - 1]['line'] : null,
|
'line' => $trace[$i - 1]['line'] ?? null,
|
||||||
'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null,
|
'function' => $trace[$i]['function'] ?? null,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +89,7 @@ class Introspection
|
||||||
*
|
*
|
||||||
* @return bool True if the class or function should get skipped, otherwise false
|
* @return bool True if the class or function should get skipped, otherwise false
|
||||||
*/
|
*/
|
||||||
private function isTraceClassOrSkippedFunction(array $trace, $index)
|
private function isTraceClassOrSkippedFunction(array $trace, int $index): bool
|
||||||
{
|
{
|
||||||
if (!isset($trace[$index])) {
|
if (!isset($trace[$index])) {
|
||||||
return false;
|
return false;
|
|
@ -22,7 +22,7 @@
|
||||||
namespace Friendica\Test\src\Core\Logger;
|
namespace Friendica\Test\src\Core\Logger;
|
||||||
|
|
||||||
use Friendica\Test\MockedTest;
|
use Friendica\Test\MockedTest;
|
||||||
use Friendica\Util\Introspection;
|
use Friendica\Core\Logger\Util\Introspection;
|
||||||
use Mockery\MockInterface;
|
use Mockery\MockInterface;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Psr\Log\LogLevel;
|
use Psr\Log\LogLevel;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
namespace Friendica\Test\src\Core\Logger;
|
namespace Friendica\Test\src\Core\Logger;
|
||||||
|
|
||||||
use Friendica\Core\Logger\Type\SyslogLogger;
|
use Friendica\Core\Logger\Type\SyslogLogger;
|
||||||
use Friendica\Util\Introspection;
|
use Friendica\Core\Logger\Util\Introspection;
|
||||||
use Psr\Log\LogLevel;
|
use Psr\Log\LogLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue