For my actual project i use a mix of klein.php for routing and KLogger for filelogging.
The logger is instanced in general in the app handler, and available in the routing classes which call "klein" routes inside:
<?php
namespace Router\Routes;
class GetHostInformations extends Base{
public function init() {
$that = $this;
$this->getLogger()->debug('works');
$this->getRouter()->getKlein()->respond('GET', '/hello-world', function (
\Klein\Request $request,
\Klein\Response $response,
\Klein\ServiceProvider $service,
\Klein\App $app) use (&$that) {
$that->getLogger()->debug('not working..'); // doesn work
$this->getLogger()->debug('not working..'); // doesn work either
return "hello-world";
});
}
}
If i request this route, all log files will be written, instead of the debug logs in the lambda function of klein.
Instead i get following error:
Warning: fwrite(): 38 is not a valid stream resource in C:\xampp\htdocs\project\application\vendor\katzgrau\klogger\src\Logger.php on line 227
Fatal error: Uncaught exception 'RuntimeException' with message 'The file could not be written to. Check that appropriate permissions have been set.' in C:\xampp\htdocs\project\application\vendor\katzgrau\klogger\src\Logger.php:228
If i check the filehandle in klogger vendor, i dont see any errors, i everytime get:
Resource id #38
But if i check the handle via stream_get_meta_data it returns false on the lambda call.
PHP Version 5.6.3
For my actual project i use a mix of klein.php for routing and KLogger for filelogging.
The logger is instanced in general in the app handler, and available in the routing classes which call "klein" routes inside:
If i request this route, all log files will be written, instead of the debug logs in the lambda function of klein.
Instead i get following error:
If i check the filehandle in klogger vendor, i dont see any errors, i everytime get:
Resource id #38
But if i check the handle via
stream_get_meta_data
it returnsfalse
on the lambda call.Why does the filehandle break on the lambda call?