Skip to content

Instantly share code, notes, and snippets.

@AV4TAr
Created June 4, 2013 20:01
Show Gist options
  • Save AV4TAr/5709067 to your computer and use it in GitHub Desktop.
Save AV4TAr/5709067 to your computer and use it in GitHub Desktop.
Loguear todos los eventos de ZF2 al error_log
<?php
class Module {
//...
public function onBootstrap(EventInterface $e)
{
//...
$eventManager = $e->getApplication()->getEventManager();
$sharedEventManager = $eventManager->getSharedManager();
$sharedEventManager->attach('*',
'*',
function ($e)
{
$event = $e->getName();
$target = get_class($e->getTarget());
$params = $e->getParams();
$output = sprintf(
'Event "%s" was triggered on target "%s", with parameters %s',
$event,
$target,
json_encode($params));
error_log($output);
// Return true so this listener doesn't break the validator
// chain triggering session.validate listeners
return true;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment