mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-04 04:07:39 +02:00
Merge remote-tracking branch 'neclimdul/SoapFaultObjectFailure'
This commit is contained in:
@@ -180,8 +180,12 @@ class LineFormatter extends NormalizerFormatter
|
|||||||
$str .= ' faultactor: ' . $e->faultactor;
|
$str .= ' faultactor: ' . $e->faultactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($e->detail) && (is_string($e->detail) || is_object($e->detail) || is_array($e->detail))) {
|
if (isset($e->detail)) {
|
||||||
$str .= ' detail: ' . (is_string($e->detail) ? $e->detail : reset($e->detail));
|
if (is_string($e->detail)) {
|
||||||
|
$str .= ' detail: ' . $e->detail;
|
||||||
|
} elseif (is_object($e->detail) || is_array($e->detail)) {
|
||||||
|
$str .= ' detail: ' . $this->toJson($e->detail, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$str .= '): ' . $e->getMessage() . ' at ' . $e->getFile() . ':' . $e->getLine() . ')';
|
$str .= '): ' . $e->getMessage() . ' at ' . $e->getFile() . ':' . $e->getLine() . ')';
|
||||||
|
@@ -192,6 +192,19 @@ class LineFormatterTest extends \PHPUnit\Framework\TestCase
|
|||||||
$path = str_replace('\\/', '/', json_encode(__FILE__));
|
$path = str_replace('\\/', '/', json_encode(__FILE__));
|
||||||
|
|
||||||
$this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (SoapFault(code: 0 faultcode: foo faultactor: hello detail: world): bar at '.substr($path, 1, -1).':'.(__LINE__ - 8).')"} []'."\n", $message);
|
$this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (SoapFault(code: 0 faultcode: foo faultactor: hello detail: world): bar at '.substr($path, 1, -1).':'.(__LINE__ - 8).')"} []'."\n", $message);
|
||||||
|
|
||||||
|
$message = $formatter->format([
|
||||||
|
'level_name' => 'CRITICAL',
|
||||||
|
'channel' => 'core',
|
||||||
|
'context' => ['exception' => new \SoapFault('foo', 'bar', 'hello', (object) ['bar' => (object) ['biz' => 'baz'], 'foo' => 'world'])],
|
||||||
|
'datetime' => new \DateTimeImmutable,
|
||||||
|
'extra' => [],
|
||||||
|
'message' => 'foobar',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$path = str_replace('\\/', '/', json_encode(__FILE__));
|
||||||
|
|
||||||
|
$this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (SoapFault(code: 0 faultcode: foo faultactor: hello detail: {\"bar\":{\"biz\":\"baz\"},\"foo\":\"world\"}): bar at '.substr($path, 1, -1).':'.(__LINE__ - 8).')"} []'."\n", $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBatchFormat()
|
public function testBatchFormat()
|
||||||
|
@@ -107,15 +107,15 @@ class NormalizerFormatterTest extends TestCase
|
|||||||
], $formatted);
|
], $formatted);
|
||||||
|
|
||||||
$formatter = new NormalizerFormatter('Y-m-d');
|
$formatter = new NormalizerFormatter('Y-m-d');
|
||||||
$e = new \SoapFault('foo', 'bar', 'hello', (object) array('bar' => (object) array('biz' => 'baz'), 'foo' => 'world'));
|
$e = new \SoapFault('foo', 'bar', 'hello', (object) ['bar' => (object) ['biz' => 'baz'], 'foo' => 'world']);
|
||||||
$formatted = $formatter->format(array(
|
$formatted = $formatter->format([
|
||||||
'exception' => $e,
|
'exception' => $e,
|
||||||
));
|
]);
|
||||||
|
|
||||||
unset($formatted['exception']['trace']);
|
unset($formatted['exception']['trace']);
|
||||||
|
|
||||||
$this->assertEquals(array(
|
$this->assertEquals([
|
||||||
'exception' => array(
|
'exception' => [
|
||||||
'class' => 'SoapFault',
|
'class' => 'SoapFault',
|
||||||
'message' => 'bar',
|
'message' => 'bar',
|
||||||
'code' => 0,
|
'code' => 0,
|
||||||
@@ -123,8 +123,8 @@ class NormalizerFormatterTest extends TestCase
|
|||||||
'faultcode' => 'foo',
|
'faultcode' => 'foo',
|
||||||
'faultactor' => 'hello',
|
'faultactor' => 'hello',
|
||||||
'detail' => '{"bar":{"biz":"baz"},"foo":"world"}',
|
'detail' => '{"bar":{"biz":"baz"},"foo":"world"}',
|
||||||
),
|
],
|
||||||
), $formatted);
|
], $formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormatToStringExceptionHandle()
|
public function testFormatToStringExceptionHandle()
|
||||||
|
Reference in New Issue
Block a user