PluginProbe
Code Profiler – WordPress Performance Profiling and Debugging Made Easy / 1.9.6
Code Profiler – WordPress Performance Profiling and Debugging Made Easy v1.9.6
1.9.6 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 All 41 releases
← All changes | lib/menu_log.php +51 -15 1.41.9.6 View file →
@@ -6,36 +6,40 @@
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
21 +require __DIR__.'/class-logs.php';
22 +
19 23 // Delete the log?
20 24 if (! empty( $_POST['cp-delete-log'] ) ) {
21 - if ( empty( $_POST['cp_nonce'] ) || ! wp_verify_nonce( $_POST['cp_nonce'], 'cp_delete_log' ) ) {
25 + if ( empty( $_POST['cp_nonce'] ) || ! wp_verify_nonce( $_POST['cp_nonce'], 'cp_delete_log') ) {
22 26 printf(
23 27 CODE_PROFILER_ERROR_NOTICE,
24 - esc_html__('Security nonce is missing, try to reload the page.', 'code-profiler' )
28 + esc_html__('Security nonce is missing, try to reload the page.', 'code-profiler')
25 29 );
26 30
27 31 } else {
28 - $res = file_put_contents( CODE_PROFILER_LOG, "<?php exit; ?>\n" );
32 + $res = file_put_contents( CODE_PROFILER_LOG, "<?php exit; ?>\n");
29 33 if ( $res !== false ) {
30 34 printf(
31 35 CODE_PROFILER_UPDATE_NOTICE,
32 - esc_html__('The log was deleted.', 'code-profiler' )
36 + esc_html__('The log was deleted.', 'code-profiler')
33 37 );
34 38 } else {
35 39 printf(
36 40 CODE_PROFILER_ERROR_NOTICE,
37 - esc_html__('Cannot delete the log, make sure it is writable.', 'code-profiler' )
41 + esc_html__('Cannot delete the log, make sure it is writable.', 'code-profiler')
38 42 );
39 43 }
40 44 }
41 45 }
@@ -43,21 +47,23 @@
43 47 <script>
44 48 'use strict';
45 49 var cplog_array = new Array();
46 50 <?php
47 -$info = 0; $warn = 0; $error = 0; $logline = '';
51 +$info = 0; $warn = 0; $error = 0; $debug = 0; $logline = '';
48 52 if ( file_exists( CODE_PROFILER_LOG ) ) {
49 53
50 -
51 54 $lines = array();
52 55 $lines = file( CODE_PROFILER_LOG, FILE_SKIP_EMPTY_LINES );
53 56 $i = 0;
54 - $facility = array( 1 => 'INFO ', 2 => 'WARN ', 4 => 'ERROR' );
57 + $facility = array( 1 => 'INFO ', 2 => 'WARN ', 4 => 'ERROR', 8 => 'DEBUG');
55 58 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 . '] = "' .
59 + if ( $line[0] == '<') { continue; }
60 + list( $date, $level, $string ) = explode('~~', $line, 3 );
61 + if (! isset( $facility[$level] ) ) {
62 + continue;
63 + }
64 + $date = date('d-M-y H:i:s', $date );
65 + echo 'cplog_array[' . $i . '] = "' .
60 66 rawurlencode( "$level~~$date {$facility[$level]} $string" ) ."\";\n";
61 67 ++$i;
62 68 if ( $level == 1 ) {
63 69 $info = 1;
@@ -64,8 +70,11 @@
64 70 } elseif ( $level == 2 ) {
65 71 $warn = 1;
66 72 } elseif ( $level == 4 ) {
67 73 $error = 1;
74 + } elseif ( $level == 8 ) {
75 + $debug = 1;
76 + continue;
68 77 }
69 78 $logline .= "$date {$facility[$level]} $string";
70 79 }
71 80 }
@@ -80,8 +89,9 @@
80 89 }
81 90
82 91 echo code_profiler_display_tabs( 4 );
83 92 ?>
93 +<h3><?php esc_html_e('Code Profiler log', 'code-profiler'); ?></h3>
84 94 <form name="cplogform" method="post">
85 95 <table class="form-table">
86 96 <tr>
87 97 <td width="100%">
@@ -118,15 +128,41 @@
118 128 <label for="cxerror">
119 129 <input id="cxerror" type="checkbox" name="error"<?php echo $error_checked ?><?php disabled( $error, 0 ) ?> onClick="cpjs_filter_log();"<?php echo $disabled ?> />
120 130 <span style="display: inline-block"><?php esc_html_e('Error', 'code-profiler') ?></span>&nbsp;
121 131 </label>
132 + &nbsp;&nbsp;&nbsp;&nbsp;
133 + <label for="cxdebug">
134 + <input id="cxdebug" type="checkbox" name="debug"<?php disabled( $debug, 0 ) ?> onClick="cpjs_filter_log();"<?php echo $disabled ?> />
135 + <span style="display: inline-block"><?php esc_html_e('Debug', 'code-profiler') ?></span>&nbsp;
136 + </label>
122 137 </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, '' ) ?> />
138 + <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 139 <?php wp_nonce_field('cp_delete_log', 'cp_nonce', 0); ?>
140 + <p class="description"><?php esc_html_e('The log is deleted automatically when it reaches 100KB.', 'code-profiler') ?></p>
125 141 </td>
126 142 </tr>
127 143 </table>
128 144 </form>
145 +
146 +<h3><?php esc_html_e('HTTP response log', 'code-profiler'); ?></h3>
147 +<table class="form-table">
148 + <tr>
149 + <td width="100%">
150 + <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
151 + /**
152 + * Display the last HTTP response log.
153 + */
154 + $log = CodeProfiler_Logs::get_HTTP_log();
155 + if ( $log === false ) {
156 + echo "\n\n > " . esc_html__('The HTTP response log is empty.', 'code-profiler');
157 + } else {
158 + echo esc_textarea( $log );
159 + }
160 + ?></textarea>
161 + <p class="description"><?php esc_html_e('The log shows the HTTP request and its payload, the 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