PluginProbe ʕ •ᴥ•ʔ
XML Sitemap & Google News / trunk
XML Sitemap & Google News vtrunk
5.7.7 5.7.5 5.7.6 5.7.4 trunk 1.0 2.0 2.1 3.0 3.2 3.3 3.4 3.5 3.6.1 3.7.4 3.8.8 3.9.3 4.0.1 4.1.4 4.2.3 4.3.2 4.4.1 4.5.1 4.6.3 4.7.5 4.8.3 4.9.4 5.0.7 5.1.2 5.2.7 5.3.6 5.4.6 5.4.9 5.5.1 5.5.2 5.5.3 5.5.4 5.5.5 5.5.6 5.5.7 5.5.8 5.5.9 5.6 5.6.1 5.6.2 5.6.3 5.7 5.7.1 5.7.2 5.7.3
xml-sitemap-feed / inc / functions-debugging.php
xml-sitemap-feed / inc Last commit date
admin 2 months ago compat 2 months ago class-bwt-api-handler.php 4 months ago class-bwt-connect.php 7 months ago class-gsc-api-handler.php 4 months ago class-gsc-connect.php 4 months ago class-gsc-oauth-handler.php 7 months ago class-secret.php 7 months ago class-sitemap-core.php 7 months ago class-sitemap-news.php 3 months ago class-sitemap-plugin.php 3 months ago class-sitemap.php 2 months ago class-sitemaps-provider-custom.php 7 months ago class-sitemaps-provider-external.php 7 months ago class-sitemaps-provider-news.php 7 months ago class-xmlsitemapfeed.php 3 months ago functions-debugging.php 1 year ago functions-pluggable.php 1 year ago functions.php 3 months ago translations.php 4 months ago
functions-debugging.php
101 lines
1 <?php
2 /**
3 * Debugging Functions
4 *
5 * @package XML Sitemap & Google News
6 * @since 5.4
7 */
8
9 /**
10 * Error messages for Nginx Helper Purge URLs
11 *
12 * @param array $urls Purged URLs.
13 */
14 function xmlsf_debug_nginx_helper_purge_urls( $urls ) {
15 if ( ! WP_DEBUG_LOG ) {
16 return;
17 }
18
19 error_log( 'NGINX Helper purge urls array:' );
20 error_log( print_r( $urls, true ) );
21 }
22
23 add_action( 'xmlsf_nginx_helper_purge_urls', 'xmlsf_debug_nginx_helper_purge_urls' );
24
25 /**
26 * Usage info for debugging
27 *
28 * @since 5.4
29 * @return void
30 */
31 function xmlsf_debug_usage() {
32 global $wpdb, $EZSQL_ERROR;
33
34 $num = get_num_queries();
35 $limit = ini_get( 'memory_limit' );
36
37 // Query errors.
38 $err = 'None encountered.';
39 if ( is_array( $EZSQL_ERROR ) && count( $EZSQL_ERROR ) ) {
40 $err = '';
41 $i = 1;
42 foreach ( $EZSQL_ERROR as $e ) {
43 $err .= PHP_EOL . $i . ': ' . implode( PHP_EOL, $e ) . PHP_EOL;
44 ++$i;
45 }
46 }
47 // Saved queries.
48 if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES ) {
49 $saved = PHP_EOL . print_r( $wpdb->queries, true );
50 } else {
51 $saved = 'Set SAVEQUERIES to show saved database queries here.';
52 }
53 // Memory usage.
54 if ( function_exists( 'memory_get_peak_usage' ) ) {
55 $mem = round( memory_get_peak_usage() / 1024 / 1024, 2 ) . 'M';
56 } else {
57 $mem = 'Not availabe.';
58 }
59 // System load.
60 if ( function_exists( 'sys_getloadavg' ) ) {
61 $load = sys_getloadavg()[0];
62 } else {
63 $load = 'Not available.';
64 }
65
66 echo '<!-- Queries executed: ' . esc_xml( $num ) . ' | Peak memory usage: ' . esc_xml( $mem ) . '| Memory limit: ' . esc_xml( $limit ) . ' -->' . PHP_EOL;
67 echo '<!-- Query errors: ' . esc_xml( $err ) . ' -->' . PHP_EOL;
68 echo '<!-- Queries: ' . $saved . ' -->' . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
69 echo '<!-- Average system load during the last minute: ' . esc_xml( $load ) . ' -->' . PHP_EOL;
70 }
71
72 add_action(
73 'xmlsf_sitemap_loaded',
74 function () {
75 WP_DEBUG_LOG && add_action( 'shutdown', 'xmlsf_debug_usage' );
76 }
77 );
78
79 add_action(
80 'xmlsf_sitemap_news_loaded',
81 function () {
82 WP_DEBUG_LOG && add_action( 'shutdown', 'xmlsf_debug_usage' );
83 }
84 );
85
86 add_action(
87 'xmlsf_install',
88 function () {
89 // Kilroy was here.
90 WP_DEBUG_LOG && error_log( 'XML Sitemap Feeds version ' . XMLSF_VERSION . ' installed.' );
91 }
92 );
93
94 add_action(
95 'xmlsf_upgrade',
96 function ( $db_version ) {
97 // Kilroy was here.
98 WP_DEBUG_LOG && error_log( 'XML Sitemap Feeds upgraded from ' . $db_version . ' to ' . XMLSF_VERSION );
99 }
100 );
101