mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-25 10:36:33 +02:00
Move getClass method to a Utils class, refs #1190
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
namespace Monolog\Formatter;
|
||||
|
||||
use Exception;
|
||||
use Monolog\Registry;
|
||||
use Monolog\Utils;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@@ -180,11 +180,11 @@ class JsonFormatter extends NormalizerFormatter
|
||||
{
|
||||
// TODO 2.0 only check for Throwable
|
||||
if (!$e instanceof Exception && !$e instanceof Throwable) {
|
||||
throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Registry::getClass($e));
|
||||
throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Utils::getClass($e));
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'class' => Registry::getClass($e),
|
||||
'class' => Utils::getClass($e),
|
||||
'message' => $e->getMessage(),
|
||||
'code' => $e->getCode(),
|
||||
'file' => $e->getFile().':'.$e->getLine(),
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Monolog\Formatter;
|
||||
|
||||
use Monolog\Registry;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Formats incoming records into a one-line string
|
||||
@@ -131,17 +131,17 @@ class LineFormatter extends NormalizerFormatter
|
||||
{
|
||||
// TODO 2.0 only check for Throwable
|
||||
if (!$e instanceof \Exception && !$e instanceof \Throwable) {
|
||||
throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Registry::getClass($e));
|
||||
throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Utils::getClass($e));
|
||||
}
|
||||
|
||||
$previousText = '';
|
||||
if ($previous = $e->getPrevious()) {
|
||||
do {
|
||||
$previousText .= ', '.Registry::getClass($previous).'(code: '.$previous->getCode().'): '.$previous->getMessage().' at '.$previous->getFile().':'.$previous->getLine();
|
||||
$previousText .= ', '.Utils::getClass($previous).'(code: '.$previous->getCode().'): '.$previous->getMessage().' at '.$previous->getFile().':'.$previous->getLine();
|
||||
} while ($previous = $previous->getPrevious());
|
||||
}
|
||||
|
||||
$str = '[object] ('.Registry::getClass($e).'(code: '.$e->getCode().'): '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().$previousText.')';
|
||||
$str = '[object] ('.Utils::getClass($e).'(code: '.$e->getCode().'): '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().$previousText.')';
|
||||
if ($this->includeStacktraces) {
|
||||
$str .= "\n[stacktrace]\n".$e->getTraceAsString()."\n";
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace Monolog\Formatter;
|
||||
|
||||
use Monolog\Registry;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Formats a record for use with the MongoDBHandler.
|
||||
@@ -77,7 +77,7 @@ class MongoDBFormatter implements FormatterInterface
|
||||
protected function formatObject($value, $nestingLevel)
|
||||
{
|
||||
$objectVars = get_object_vars($value);
|
||||
$objectVars['class'] = Registry::getClass($value);
|
||||
$objectVars['class'] = Utils::getClass($value);
|
||||
|
||||
return $this->formatArray($objectVars, $nestingLevel);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ class MongoDBFormatter implements FormatterInterface
|
||||
protected function formatException(\Exception $exception, $nestingLevel)
|
||||
{
|
||||
$formattedException = array(
|
||||
'class' => Registry::getClass($exception),
|
||||
'class' => Utils::getClass($exception),
|
||||
'message' => $exception->getMessage(),
|
||||
'code' => $exception->getCode(),
|
||||
'file' => $exception->getFile() . ':' . $exception->getLine(),
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace Monolog\Formatter;
|
||||
|
||||
use Exception;
|
||||
use Monolog\Registry;
|
||||
use Monolog\Utils;
|
||||
|
||||
/**
|
||||
* Normalizes incoming records to remove objects/resources so it's easier to dump to various targets
|
||||
@@ -109,7 +109,7 @@ class NormalizerFormatter implements FormatterInterface
|
||||
$value = $this->toJson($data, true);
|
||||
}
|
||||
|
||||
return sprintf("[object] (%s: %s)", Registry::getClass($data), $value);
|
||||
return sprintf("[object] (%s: %s)", Utils::getClass($data), $value);
|
||||
}
|
||||
|
||||
if (is_resource($data)) {
|
||||
@@ -123,11 +123,11 @@ class NormalizerFormatter implements FormatterInterface
|
||||
{
|
||||
// TODO 2.0 only check for Throwable
|
||||
if (!$e instanceof Exception && !$e instanceof \Throwable) {
|
||||
throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Registry::getClass($e));
|
||||
throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.Utils::getClass($e));
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'class' => Registry::getClass($e),
|
||||
'class' => Utils::getClass($e),
|
||||
'message' => $e->getMessage(),
|
||||
'code' => $e->getCode(),
|
||||
'file' => $e->getFile().':'.$e->getLine(),
|
||||
@@ -160,7 +160,7 @@ class NormalizerFormatter implements FormatterInterface
|
||||
// as a class name to avoid any unexpected leak of sensitive information
|
||||
$frame['args'] = array_map(function ($arg) {
|
||||
if (is_object($arg) && !($arg instanceof \DateTime || $arg instanceof \DateTimeInterface)) {
|
||||
return sprintf("[object] (%s)", Registry::getClass($arg));
|
||||
return sprintf("[object] (%s)", Utils::getClass($arg));
|
||||
}
|
||||
|
||||
return $arg;
|
||||
|
||||
Reference in New Issue
Block a user