Permalink
Browse files

fix(logging): Log messages no longer discarded

Logged messages are no longer thrown away during action and cache requests.
Also the log-to-screen feature of the developers plugin no longer throws
away messages after the page display has occurred.

In both cases, these errors likely end up in the system error log.

Fixes #9244
  • Loading branch information...
mrclay committed Dec 18, 2015
1 parent a8de1c4 commit 5020c5251f35c8bd83b5b1472eafd34d96a77a35
@@ -202,6 +202,16 @@ protected function process($data, $display, $level) {
$display = false;
}
// don't display in simplecache requests
$this_url = current_page_url();
$site_url = elgg_get_site_url();
if (0 === strpos($this_url, $site_url)) {
$path = substr($this_url, strlen($site_url));
if (preg_match('~^(cache|action)/~', $path)) {
$display = false;
}
}
if ($display == true) {
echo '<pre class="elgg-logger-data">';
echo htmlspecialchars(print_r($data, true), ENT_QUOTES, 'UTF-8');
View
@@ -1415,6 +1415,7 @@ function _elgg_shutdown_hook() {
global $START_MICROTIME;
try {
_elgg_services()->logger->setDisplay(false);
elgg_trigger_event('shutdown', 'system');
$time = (float)(microtime(true) - $START_MICROTIME);
View
@@ -38,13 +38,21 @@ function developers_process_settings() {
ini_set('display_errors', (int)!empty($settings['display_errors']));
if (!empty($settings['screen_log'])) {
$cache = new ElggLogCache();
elgg_set_config('log_cache', $cache);
elgg_register_plugin_hook_handler('debug', 'log', array($cache, 'insertDump'));
elgg_register_plugin_hook_handler('view_vars', 'page/elements/html', function($hook, $type, $vars, $params) {
$vars['body'] .= elgg_view('developers/log');
return $vars;
});
// don't show in action/simplecache
$this_url = current_page_url();
$site_url = elgg_get_site_url();
if (0 === strpos($this_url, $site_url)) {
$path = substr($this_url, strlen($site_url));
if (!preg_match('~^(cache|action)/~', $path)) {
$cache = new ElggLogCache();
elgg_set_config('log_cache', $cache);
elgg_register_plugin_hook_handler('debug', 'log', array($cache, 'insertDump'));
elgg_register_plugin_hook_handler('view_vars', 'page/elements/html', function($hook, $type, $vars, $params) {
$vars['body'] .= elgg_view('developers/log');
return $vars;
});
}
}
}
if (!empty($settings['show_strings'])) {
@@ -6,6 +6,9 @@
$cache = elgg_get_config('log_cache');
$items = $cache->get();
// stop collecting messages
elgg_unregister_plugin_hook_handler('debug', 'log', [$cache, 'insertDump']);
$pres = array();
if ($items) {
foreach ($items as $item) {

0 comments on commit 5020c52

Please sign in to comment.