PluginProbe
Code Profiler – WordPress Performance Profiling and Debugging Made Easy / 1.7.4
Code Profiler – WordPress Performance Profiling and Debugging Made Easy v1.7.4
1.9.5 1.9.4 1.9.3 trunk 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.6 1.6.1 1.6.10 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 All 40 releases
← All changes | lib/menu_log.php +51 -15 1.51.7.4 View file →
@@ -6,13 +6,15 @@
6 6 | | | / _ \ / _` |/ _ \ | |_) | '__/ _ \| |_| | |/ _ \ '__| |
7 7 | | |__| (_) | (_| | __/ | __/| | | (_) | _| | | __/ | |
8 8 | \____\___/ \__,_|\___| |_| |_| \___/|_| |_|_|\___|_| |
9 9 | |
10 - | (c) Jerome Bruandet ~ https://code-profiler.com/ |
10 + | (c) Jerome Bruandet ~ https://nintechnet.com/codeprofiler/ |
11 11 +=====================================================================+
12 12 */
13 13
14 -if (! defined( 'ABSPATH' ) ) { die( 'Forbidden' ); }
14 +if (! defined('ABSPATH') ) {
15 + die('Forbidden');
16 +}
15 17
16 18 // =====================================================================
17 19 // Display the profiler's log.
18 20
@@ -17,25 +19,25 @@
17 19 // Display the profiler's log.
18 20
19 21 // Delete the log?
20 22 if (! empty( $_POST['cp-delete-log'] ) ) {
21 - if ( empty( $_POST['cp_nonce'] ) || ! wp_verify_nonce( $_POST['cp_nonce'], 'cp_delete_log' ) ) {
23 + if ( empty( $_POST['cp_nonce'] ) || ! wp_verify_nonce( $_POST['cp_nonce'], 'cp_delete_log') ) {
22 24 printf(
23 25 CODE_PROFILER_ERROR_NOTICE,
24 - esc_html__('Security nonce is missing, try to reload the page.', 'code-profiler' )
26 + esc_html__('Security nonce is missing, try to reload the page.', 'code-profiler')
25 27 );
26 28
27 29 } else {
28 - $res = file_put_contents( CODE_PROFILER_LOG, "<?php exit; ?>\n" );
30 + $res = file_put_contents( CODE_PROFILER_LOG, "<?php exit; ?>\n");
29 31 if ( $res !== false ) {
30 32 printf(
31 33 CODE_PROFILER_UPDATE_NOTICE,
32 - esc_html__('The log was deleted.', 'code-profiler' )
34 + esc_html__('The log was deleted.', 'code-profiler')
33 35 );
34 36 } else {
35 37 printf(
36 38 CODE_PROFILER_ERROR_NOTICE,
37 - esc_html__('Cannot delete the log, make sure it is writable.', 'code-profiler' )
39 + esc_html__('Cannot delete the log, make sure it is writable.', 'code-profiler')
38 40 );
39 41 }
40 42 }
41 43 }
@@ -43,21 +45,23 @@
43 45 <script>
44 46 'use strict';
45 47 var cplog_array = new Array();
46 48 <?php
47 -$info = 0; $warn = 0; $error = 0; $logline = '';
49 +$info = 0; $warn = 0; $error = 0; $debug = 0; $logline = '';
48 50 if ( file_exists( CODE_PROFILER_LOG ) ) {
49 51
50 -
51 52 $lines = array();
52 53 $lines = file( CODE_PROFILER_LOG, FILE_SKIP_EMPTY_LINES );
53 54 $i = 0;
54 - $facility = array( 1 => 'INFO ', 2 => 'WARN ', 4 => 'ERROR' );
55 + $facility = array( 1 => 'INFO ', 2 => 'WARN ', 4 => 'ERROR', 8 => 'DEBUG');
55 56 foreach( $lines as $line ) {
56 - if ( $line[0] == '<' ) { continue; }
57 - list( $date, $level, $string ) = explode( '~~', $line, 3 );
58 - $date = date( 'd-M-y H:i:s', $date );
59 - echo 'cplog_array[' . (int)$i . '] = "' .
57 + if ( $line[0] == '<') { continue; }
58 + list( $date, $level, $string ) = explode('~~', $line, 3 );
59 + if (! isset( $facility[$level] ) ) {
60 + continue;
61 + }
62 + $date = date('d-M-y H:i:s', $date );
63 + echo 'cplog_array[' . $i . '] = "' .
60 64 rawurlencode( "$level~~$date {$facility[$level]} $string" ) ."\";\n";
61 65 ++$i;
62 66 if ( $level == 1 ) {
63 67 $info = 1;
@@ -64,8 +68,11 @@
64 68 } elseif ( $level == 2 ) {
65 69 $warn = 1;
66 70 } elseif ( $level == 4 ) {
67 71 $error = 1;
72 + } elseif ( $level == 8 ) {
73 + $debug = 1;
74 + continue;
68 75 }
69 76 $logline .= "$date {$facility[$level]} $string";
70 77 }
71 78 }
@@ -80,8 +87,9 @@
80 87 }
81 88
82 89 echo code_profiler_display_tabs( 4 );
83 90 ?>
91 +<h3><?php esc_html_e('Code Profiler log', 'code-profiler'); ?></h3>
84 92 <form name="cplogform" method="post">
85 93 <table class="form-table">
86 94 <tr>
87 95 <td width="100%">
@@ -118,15 +126,43 @@
118 126 <label for="cxerror">
119 127 <input id="cxerror" type="checkbox" name="error"<?php echo $error_checked ?><?php disabled( $error, 0 ) ?> onClick="cpjs_filter_log();"<?php echo $disabled ?> />
120 128 <span style="display: inline-block"><?php esc_html_e('Error', 'code-profiler') ?></span>&nbsp;
121 129 </label>
130 + &nbsp;&nbsp;&nbsp;&nbsp;
131 + <label for="cxdebug">
132 + <input id="cxdebug" type="checkbox" name="debug"<?php disabled( $debug, 0 ) ?> onClick="cpjs_filter_log();"<?php echo $disabled ?> />
133 + <span style="display: inline-block"><?php esc_html_e('Debug', 'code-profiler') ?></span>&nbsp;
134 + </label>
122 135 </p>
123 - <input type="submit" onclick="return cpjs_delete_log();" name="cp-delete-log" class="button-primary" value="<?php esc_attr_e('Delete log', 'code-profiler') ?>"<?php disabled( $logline, '' ) ?> />
136 + <input type="submit" onclick="return cpjs_delete_log();" name="cp-delete-log" class="button button-primary" value="<?php esc_attr_e('Delete log', 'code-profiler') ?>"<?php disabled( $logline, '') ?> />
124 137 <?php wp_nonce_field('cp_delete_log', 'cp_nonce', 0); ?>
138 + <p class="description"><?php esc_html_e('The log is deleted automatically when it reaches 100KB.', 'code-profiler') ?></p>
125 139 </td>
126 140 </tr>
127 141 </table>
128 142 </form>
143 +
144 +<h3><?php esc_html_e('HTTP response log', 'code-profiler'); ?></h3>
145 +<table class="form-table">
146 + <tr>
147 + <td width="100%">
148 + <textarea dir="auto" name="cptxtlog" class="large-text code" style="height:<?php echo $th; ?>px;" wrap="off" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"><?php
149 +
150 + /**
151 + * Search for an eventual "last_request.1727412303.5681.log" file.
152 + */
153 + $file = code_profiler_glob( CODE_PROFILER_UPLOAD_DIR, '^last_request\.\d+?\.\d+?\.log$', true );
154 + if ( empty( $file[0] ) ) {
155 + echo "\n\n > " . esc_html__('The HTTP response log is empty.', 'code-profiler');
156 + } else {
157 + $log = file_get_contents( $file[0] );
158 + echo esc_textarea( $log );
159 + }
160 + ?></textarea>
161 + <p class="description"><?php esc_html_e('The log shows the HTTP response headers and body for the last profile.', 'code-profiler') ?></p>
162 + </td>
163 + </tr>
164 +</table>
129 165 <?php
130 166
131 167 // =====================================================================
132 168 // EOF