function diagnostic($level, $out, $persist = NULL, $since = NULL, $mostRecent = NULL) { global $feedwordpress_admin_footer; $output = get_option('feedwordpress_diagnostics_output', array()); $dlog = get_option('feedwordpress_diagnostics_log', array()); $diagnostic_nesting = count(explode(":", $level)); if (FeedWordPress::diagnostic_on($level)) { foreach ($output as $method) { switch ($method) { case 'echo': if (!FeedWordPress::update_requested()) { echo "<div><pre><strong>Diag" . str_repeat('====', $diagnostic_nesting - 1) . '|</strong> ' . $out . "</pre></div>"; } break; case 'echo_in_cronjob': if (FeedWordPress::update_requested()) { echo FeedWordPress::log_prefix() . " " . $out . "\n"; } break; case 'admin_footer': $feedwordpress_admin_footer[] = $out; break; case 'error_log': error_log(FeedWordPress::log_prefix() . ' ' . $out); break; case 'email': if (is_null($persist)) { $sect = 'occurrent'; $hook = isset($dlog['mesg'][$sect]) ? count($dlog['mesg'][$sect]) : 0; $line = array("Time" => time(), "Message" => $out); } else { $sect = 'persistent'; $hook = md5($level . "\n" . $persist); $line = array("Since" => $since, "Message" => $out, "Most Recent" => $mostRecent); } if (!isset($dlog['mesg'])) { $dlog['mesg'] = array(); } if (!isset($dlog['mesg'][$sect])) { $dlog['mesg'][$sect] = array(); } $dlog['mesg'][$sect][$hook] = $line; } } } update_option('feedwordpress_diagnostics_log', $dlog); }