diff options
Diffstat (limited to 'mod/developers')
-rw-r--r-- | mod/developers/actions/developers/settings.php | 3 | ||||
-rw-r--r-- | mod/developers/languages/en.php | 5 | ||||
-rw-r--r-- | mod/developers/start.php | 42 | ||||
-rw-r--r-- | mod/developers/views/default/admin/developers/settings.php | 6 |
4 files changed, 54 insertions, 2 deletions
diff --git a/mod/developers/actions/developers/settings.php b/mod/developers/actions/developers/settings.php index f7caf859d..811fd22c0 100644 --- a/mod/developers/actions/developers/settings.php +++ b/mod/developers/actions/developers/settings.php @@ -24,7 +24,8 @@ if ($debug) { unset_config('debug', $site->getGUID()); } -$simple_settings = array('display_errors', 'screen_log', 'show_strings', 'wrap_views'); +$simple_settings = array('display_errors', 'screen_log', 'show_strings', + 'wrap_views', 'log_events',); foreach ($simple_settings as $setting) { elgg_set_plugin_setting($setting, get_input($setting), 'developers'); } diff --git a/mod/developers/languages/en.php b/mod/developers/languages/en.php index a20241eff..42df52134 100644 --- a/mod/developers/languages/en.php +++ b/mod/developers/languages/en.php @@ -27,6 +27,8 @@ $english = array( 'developers:help:show_strings' => "This displays the translation strings used by elgg_echo().", 'developers:label:wrap_views' => "Wrap views", 'developers:help:wrap_views' => "This wraps almost every view with HTML comments. Useful for finding the view creating particular HTML.", + 'developers:label:log_events' => "Log events and plugin hooks", + 'developers:help:log_events' => "Write events and plugin hooks to the log. Warning: there are many of these per page.", 'developers:debug:off' => 'Off', 'developers:debug:error' => 'Error', @@ -36,6 +38,9 @@ $english = array( // inspection 'developers:inspect:help' => 'Inspect configuration of the Elgg framework.', + // event logging + 'developers:event_log_msg' => "%s: '%s, %s' in %s", + // theme preview 'theme_preview:general' => 'Introduction', 'theme_preview:breakout' => 'Break out of iframe', diff --git a/mod/developers/start.php b/mod/developers/start.php index 27a14b336..d9e1141e0 100644 --- a/mod/developers/start.php +++ b/mod/developers/start.php @@ -48,7 +48,12 @@ function developers_process_settings() { } if (elgg_get_plugin_setting('wrap_views', 'developers') == 1) { - register_plugin_hook('view', 'all', 'developers_wrap_views'); + elgg_register_plugin_hook_handler('view', 'all', 'developers_wrap_views'); + } + + if (elgg_get_plugin_setting('log_events', 'developers') == 1) { + elgg_register_event_handler('all', 'all', 'developers_log_events', 1); + elgg_register_plugin_hook_handler('all', 'all', 'developers_log_events', 1); } } @@ -106,6 +111,41 @@ function developers_wrap_views($hook, $type, $result, $params) { } /** +* Log the events and plugin hooks +*/ +function developers_log_events($name, $type) { + + // filter out some very common events + if ($name == 'view' || $name == 'display' || $name == 'log' || $name == 'debug') { + return; + } + if ($name == 'session:get' || $name == 'validate') { + return; + } + + $stack = debug_backtrace(); + if ($stack[2]['function'] == 'elgg_trigger_event') { + $event_type = 'Event'; + } else { + $event_type = 'Plugin hook'; + } + $function = $stack[3]['function'] . '()'; + if ($function == 'require_once' || $function == 'include_once') { + $function = $stack[3]['file']; + } + + $msg = elgg_echo('developers:event_log_msg', array( + $event_type, + $name, + $type, + $function, + )); + elgg_dump($msg, false, 'WARNING'); + + unset($stack); +} + +/** * Serve the theme preview pages * * @param array $page diff --git a/mod/developers/views/default/admin/developers/settings.php b/mod/developers/views/default/admin/developers/settings.php index d463955b6..287f4d99e 100644 --- a/mod/developers/views/default/admin/developers/settings.php +++ b/mod/developers/views/default/admin/developers/settings.php @@ -50,6 +50,12 @@ $data = array( 'value' => 1, 'checked' => elgg_get_plugin_setting('wrap_views', 'developers') == 1, ), + + 'log_events' => array( + 'type' => 'checkbox', + 'value' => 1, + 'checked' => elgg_get_plugin_setting('log_events', 'developers') == 1, + ), ); $form_vars = array('id' => 'developer-settings-form'); |