Closed pierrejochem closed 6 years ago
trace should never be empty in both http and console environment, but request_data will be empty for console environment. Do you have a specific error - step to reproduce ?
Just a simple one who should have a trace:
syntax error, unexpected end of file, expecting function (T_FUNCTION)
My config:
// config/autoload/error-hero-module.local.php or config/autoload/expressive-error-hero-module.local.php
return [
'log' => [
'ErrorHeroModuleLogger' => [
'writers' => [
[
'name' => 'db',
'options' => [
'db' => 'Zend\Db\Adapter\Adapter',
'table' => 'log',
'column' => [
'timestamp' => 'date',
'priority' => 'type',
'message' => 'event',
'extra' => [
'url' => 'url',
'file' => 'file',
'line' => 'line',
'error_type' => 'error_type',
],
],
],
],
],
],
],
'error-hero-module' => [
// it's for the enable/disable the logger functionality
'enable' => true,
// default to true, if set to true, then you can see sample:
// 1. /error-preview page ( ErrorHeroModule\Controller\ErrorPreviewController )
// 2. error-preview command (ErrorHeroModule\Controller\ErrorPreviewConsoleController) via
// php public/index.php error-preview
//
// for zf-expressive ^1.0, the disable error-preview page is by unregister 'error-preview' from this config under "routes",
// for zf-expressive ^2.0, the disable error-preview page is by unregister 'error-preview' from config/routes
//
//
// otherwise(false), you can't see them, eg: on production env.
'enable-error-preview-page' => true,
'display-settings' => [
// excluded php errors ( http://www.php.net/manual/en/errorfunc.constants.php )
'exclude-php-errors' => [
\E_USER_DEPRECATED,
],
// excluded exceptions
'exclude-exceptions' => [
\App\Exception\MyException::class, // can be an Exception class or class extends Exception class
],
// show or not error
'display_errors' => 0,
// if enable and display_errors = 0, the page will bring layout and view
'template' => [
'layout' => 'layout/layout',
'view' => 'error/default'
],
// if enable and display_errors = 0, the console will bring message
'console' => [
'message' => 'We have encountered a problem and we can not fulfill your request. An error report has been generated and sent to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience.',
],
// if enable, display_errors = 0, and request XMLHttpRequest
// on this case, the "template" key will be ignored.
'ajax' => [
'message' => <<<json
{
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title": "Internal Server Error",
"status": 500,
"detail": "We have encountered a problem and we can not fulfill your request. An error report has been generated and sent to the support team and someone will attend to this problem urgently. Please try again later. Thank you for your patience."
}
json
],
],
'logging-settings' => [
// time range for same error, file, line, url, message to be re-logged
// in seconds range, 86400 means 1 day
#'same-error-log-time-range' => 86400,
'same-error-log-time-range' => 0,
],
'email-notification-settings' => [
// set to true to activate email notification on log error event
'enable' => true,
// Zend\Mail\Message instance registered at service manager
'mail-message' => 'MailMessageService',
// Zend\Mail\Transport\TransportInterface instance registered at service manager
'mail-transport' => 'MailTransportService',
// email sender
'email-from' => 'Tester <tester@test.com>',
'email-to-send' => [
'xxx@xxx.zz'
],
],
],
// ...
];
Where the syntax error happen? in controller ? in view ? any specific sample code ?
In that case it is a view helper from me, but just to produce an error
I'm not sure I can help if there is no specific code to reproduce, you can try run command:
php public/index.php error-preview
or open http://yourzfapp/error-preview and you should get the trace value in db.
After adding this to my bjyauthorize config:
['controller' => 'ErrorHeroModule\Controller\ErrorPreviewController', 'action' => 'exception', 'roles' => ['Guest']],
Sorry my fault :-(
I get this in my web app, when I call 'error-preview':
Console output is:
+------------------------------------------------------------------------------------------------------------------------------------------------------+ |We have encountered a problem and we can not fulfill your request. An error report has been generated and sent to the support team and someone will | |attend to this problem urgently. Please try again later. Thank you for your patience. | +------------------------------------------------------------------------------------------------------------------------------------------------------+
But still no trace in db. By the way I get it in the email notification. It is only missing in the database column.
Oh, you need to define trace and request_data column config in configurations, so, should be:
'writers' => [
[
'name' => 'db',
'options' => [
'db' => 'Zend\Db\Adapter\Adapter',
'table' => 'log',
'column' => [
'timestamp' => 'date',
'priority' => 'type',
'message' => 'event',
'extra' => [
'url' => 'url',
'file' => 'file',
'line' => 'line',
'error_type' => 'error_type',
'trace' => 'trace',
'request_data' => 'request_data'
],
],
],
],
I updated documentation of configuration at readme to define trace
and request_data
columns in configuration under writer -> options -> column -> extra at https://github.com/samsonasik/ErrorHeroModule/commit/8708910293ef163d4cec0d43201ebcfa0ac493ab ,
Please try and verify that fixes the issue ;)
Yesssss, it works now :-) Thank you very much and perfect that you adapted it :-)
Very good work 👍
Is it normale that the db fields trace and request_data are always empty?