我正在尝试获取自定义控制台日志,而不是
2019-07-10 03:15:31 Error: [ParseError] syntax error, unexpected '}'
#0 /app/app/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/app/app/vendor...')
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass('App\\Controller\\...')
我想要json格式
{"Error":"[ParseError] syntax error, unexpected '}'"}
目前,我已经创建了一个自定义日志适配器
// Log/Engine/ApplicationLog.php
class ApplicationLog extends BaseLog
{
public $Logs;
public function __construct($options = [])
{ parent::__construct($options);
// ...
}
public function log($level, $message, array $context = [])
{
// $level = $this->getConfig('type');
$this->$message = 'Test'.$message;
}
public function error($message, array $context = [])
{
// return static::write(__FUNCTION__, '{"error":"'.$message.'"}', $context);
return write('TESTESTSTESTSTEST');
}
}
配置为
// bootstrap.php
Log::setConfig('application', [
'className' => 'Application',
'path' => LOGS,
'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
'file' => 'error',
'engine' => 'console',
]);
我正在尝试覆盖 BaseLog 错误方法以根据我的要求更改消息,但它没有调用我的自定义消息 [在从 setConfig 中删除引擎参数后它确实调用了我的函数]。欢迎提出任何建议,谢谢。