Skip to content

Commit

Permalink
Merge branch 'add-cookie-info'
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Dec 10, 2017
2 parents 75a9107 + 7ca440b commit 6b83fe7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Features
- [x] Handle only once log error for same error per configured time range.
- [x] Set default page (web access) or default message (console access) for error if configured 'display_errors' = 0.
- [x] Set default content when request is XMLHttpRequest via 'ajax' configuration.
- [x] Provide request information ( http method, raw data, query data, files data ).
- [x] Provide request information ( http method, raw data, query data, files data, and cookie data ).
- [x] Send Mail
- [x] many receivers to listed configured email
- [x] with include $_FILES into attachments on upload error.
Expand Down
3 changes: 2 additions & 1 deletion spec/Handler/Formatter/JsonSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
'body_data' => [],
'raw_data' => '',
'files_data' => [],
'cookie_data' => [],
],
],
];
Expand All @@ -53,7 +54,7 @@
$formatter = new Json();
$actual = $formatter->format($event);

expect($actual)->toBe("{\n \"timestamp\": \"2016-12-30T00:42:49+07:00\",\n \"priority\": 3,\n \"priorityName\": \"ERR\",\n \"message\": \"1: a sample error preview\",\n \"extra\": {\n \"url\": \"http://localhost/error-preview?foo=bar&page=1\",\n \"file\": \"/path/to/app/vendor/samsonasik/error-hero-module/src/Controller/ErrorPreviewController.php\",\n \"line\": 11,\n \"error_type\": \"Exception\",\n \"trace\": \"#0 /path/to/app/vendor/zendframework/zend-mvc/src/Controller/AbstractActionController.php(78): ErrorHeroModule\\\\Controller\\\\ErrorPreviewController->exceptionAction()\n #1 /path/to/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\\\\Mvc\\\\Controller\\\\AbstractActionController->onDispatch(Object(Zend\\\\Mvc\\\\MvcEvent))\n #2 /path/to/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\\\\EventManager\\\\EventManager->triggerListeners(Object(Zend\\\\Mvc\\\\MvcEvent), Object(Closure))\n #3 /path/to/app/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(105): Zend\\\\EventManager\\\\EventManager->triggerEventUntil(Object(Closure), Object(Zend\\\\Mvc\\\\MvcEvent))\n #4 /path/to/app/vendor/zendframework/zend-mvc/src/DispatchListener.php(119): Zend\\\\Mvc\\\\Controller\\\\AbstractController->dispatch(Object(Zend\\\\Http\\\\PhpEnvironment\\\\Request), Object(Zend\\\\Http\\\\PhpEnvironment\\\\Response))\n #5 /path/to/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\\\\Mvc\\\\DispatchListener->onDispatch(Object(Zend\\\\Mvc\\\\MvcEvent))\n #6 /path/to/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\\\\EventManager\\\\EventManager->triggerListeners(Object(Zend\\\\Mvc\\\\MvcEvent), Object(Closure))\n #7 /path/to/app/vendor/zendframework/zend-mvc/src/Application.php(332): Zend\\\\EventManager\\\\EventManager->triggerEventUntil(Object(Closure), Object(Zend\\\\Mvc\\\\MvcEvent))\n #8 /path/to/app/public/index.php(40): Zend\\\\Mvc\\\\Application->run()\n #9 {main}\",\n \"request_data\": {\n \"query\": {\n \"foo\": \"bar\",\n \"page\": \"1\"\n },\n \"request_method\": \"GET\",\n \"body_data\": [],\n \"raw_data\": \"\",\n \"files_data\": []\n }\n }\n}");
expect($actual)->toBe("{\n \"timestamp\": \"2016-12-30T00:42:49+07:00\",\n \"priority\": 3,\n \"priorityName\": \"ERR\",\n \"message\": \"1: a sample error preview\",\n \"extra\": {\n \"url\": \"http://localhost/error-preview?foo=bar&page=1\",\n \"file\": \"/path/to/app/vendor/samsonasik/error-hero-module/src/Controller/ErrorPreviewController.php\",\n \"line\": 11,\n \"error_type\": \"Exception\",\n \"trace\": \"#0 /path/to/app/vendor/zendframework/zend-mvc/src/Controller/AbstractActionController.php(78): ErrorHeroModule\\\\Controller\\\\ErrorPreviewController->exceptionAction()\n #1 /path/to/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\\\\Mvc\\\\Controller\\\\AbstractActionController->onDispatch(Object(Zend\\\\Mvc\\\\MvcEvent))\n #2 /path/to/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\\\\EventManager\\\\EventManager->triggerListeners(Object(Zend\\\\Mvc\\\\MvcEvent), Object(Closure))\n #3 /path/to/app/vendor/zendframework/zend-mvc/src/Controller/AbstractController.php(105): Zend\\\\EventManager\\\\EventManager->triggerEventUntil(Object(Closure), Object(Zend\\\\Mvc\\\\MvcEvent))\n #4 /path/to/app/vendor/zendframework/zend-mvc/src/DispatchListener.php(119): Zend\\\\Mvc\\\\Controller\\\\AbstractController->dispatch(Object(Zend\\\\Http\\\\PhpEnvironment\\\\Request), Object(Zend\\\\Http\\\\PhpEnvironment\\\\Response))\n #5 /path/to/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): Zend\\\\Mvc\\\\DispatchListener->onDispatch(Object(Zend\\\\Mvc\\\\MvcEvent))\n #6 /path/to/app/vendor/zendframework/zend-eventmanager/src/EventManager.php(179): Zend\\\\EventManager\\\\EventManager->triggerListeners(Object(Zend\\\\Mvc\\\\MvcEvent), Object(Closure))\n #7 /path/to/app/vendor/zendframework/zend-mvc/src/Application.php(332): Zend\\\\EventManager\\\\EventManager->triggerEventUntil(Object(Closure), Object(Zend\\\\Mvc\\\\MvcEvent))\n #8 /path/to/app/public/index.php(40): Zend\\\\Mvc\\\\Application->run()\n #9 {main}\",\n \"request_data\": {\n \"query\": {\n \"foo\": \"bar\",\n \"page\": \"1\"\n },\n \"request_method\": \"GET\",\n \"body_data\": [],\n \"raw_data\": \"\",\n \"files_data\": [],\n \"cookie_data\": []\n }\n }\n}");

});

Expand Down
6 changes: 4 additions & 2 deletions spec/Handler/Writer/MailSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,22 @@
'type' => 'text/html'
],
],
'cookie_data' => [],
]
);
});

describe('->shutdown', function () {

it('return early when eventsToMail is empty', function () {

$r = new ReflectionProperty($this->writer, 'eventsToMail');
$r->setAccessible(true);
$r->setValue($this->writer, []);

$this->writer->shutdown();
expect($this->transport)->not->toReceive('send');

});

it('set subjectPrependText if exists and eventsToMail not empty, then transport->send()', function () {
Expand Down Expand Up @@ -88,6 +89,7 @@
],
],
],
'cookie_data' => [],
]
);

Expand Down
2 changes: 2 additions & 0 deletions src/Handler/Logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ private function getRequestData()
$raw_data = $request->getContent();
$raw_data = \str_replace(\PHP_EOL, '', $raw_data);
$files_data = $request->getFiles()->toArray();
$cookie_data = (array) $request->getCookie();

return [
'query' => $query,
'request_method' => $request_method,
'body_data' => $body_data,
'raw_data' => $raw_data,
'files_data' => $files_data,
'cookie_data' => $cookie_data,
];
}

Expand Down

0 comments on commit 6b83fe7

Please sign in to comment.