23/05
2016
Small group of classes to build upon. Logs timestamps in code
This class has no dependencies and can easily be implemented in any ANAX-baed framework., (*1)
The first thing you have to do to use CLog is to add "mcknubb/log": "dev-master"
to your composer.json file and then run composer to update and install.
Once the package has been installed you have to add the logger to DI. This is done by adding this code to your "config_with_app.php"
., (*2)
$di->setShared('logger', function () { $logger = new \Mcknubb\Log\Clog(); return $logger; });
Then all you have to do is add a timestamp whereever you want to see what happens. This example is from where we add the routes., (*3)
public function add($rule, $action = null) { $this->di->logger->Timestamp(__CLASS__, __METHOD__, 'Adding route'); //.. }
Then to show the generated log you add "echo $app->logger->renderLog();"
to the end of your file like so., (*4)
// Render the response using theme engine. $app->theme->render(); echo $app->logger->renderLog();