Skip to content

Commit

Permalink
v 0.4.0
Browse files Browse the repository at this point in the history
- fix latest errors order.
- shorter display for errors in top errors.
  • Loading branch information
Darklg committed Mar 8, 2024
1 parent 6b44227 commit 62b8b26
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions wpuerrorlogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin URI: https://github.com/WordPressUtilities/wpuerrorlogs
Update URI: https://github.com/WordPressUtilities/wpuerrorlogs
Description: Make sense of your log files
Version: 0.3.1
Version: 0.4.0
Author: Darklg
Author URI: https://github.com/Darklg
Text Domain: wpuerrorlogs
Expand All @@ -20,7 +20,7 @@
}

class WPUErrorLogs {
private $plugin_version = '0.3.1';
private $plugin_version = '0.4.0';
private $plugin_settings = array(
'id' => 'wpuerrorlogs',
'name' => 'WPU Error Logs'
Expand Down Expand Up @@ -202,8 +202,7 @@ function sort_errors_by_top($errors, $max_number = 5) {
}

function sort_errors_by_latest($errors, $max_number = 5) {
$latest_errors = array_reverse($errors);
$latest_errors = array_slice($latest_errors, 0, $max_number, true);
$latest_errors = array_slice($errors, 0, $max_number, true);
foreach ($latest_errors as $i => $error) {
$latest_errors[$i]['text'] = $this->expand_error_text($error['text']);
}
Expand Down Expand Up @@ -301,7 +300,8 @@ function get_logs_from_file($file) {
$currentError['text'] = $this->minimize_error_text($currentError['text']);
$errors[] = $currentError;
}
return $errors;

return array_reverse($errors);
}

function get_error_from_line($line) {
Expand Down Expand Up @@ -346,15 +346,13 @@ function get_error_from_line($line) {

function display_content_with_toggle($content) {
$content = strip_tags($content);
if (strpos($content, "\n") === false) {
return $content;
}
$content_parts = explode("\n", $content);
if (!isset($content_parts[1])) {
$minimized_error = str_replace(ABSPATH, '', $content_parts[0]);
if ($minimized_error == $content) {
return $content;
}
$content = $content_parts[0];
$content .= '<details><summary>' . __('Full error', 'wpuerrorlogs') . '</summary><pre style="overflow:auto">' . implode("\n", $content_parts) . '</pre></details>';
$content = $minimized_error;
$content .= '<details><summary>' . __('Full error', 'wpuerrorlogs') . '</summary><pre style="overflow:auto;white-space: normal;">' . implode("\n", $content_parts) . '</pre></details>';
return $content;
}

Expand Down

0 comments on commit 62b8b26

Please sign in to comment.