{"id":205607,"date":"2011-07-26T08:00:00","date_gmt":"2011-07-26T08:00:00","guid":{"rendered":"https:\/\/www.weixiaoduo.com\/plugins\/2024\/02\/22\/wp-debug-logger\/"},"modified":"2016-12-09T19:00:00","modified_gmt":"2016-12-09T19:00:00","slug":"wp-debug-logger","status":"publish","type":"post","link":"https:\/\/www.weixiaoduo.com\/plugins\/wp-debug-logger\/","title":{"rendered":"WP Debug Logger"},"content":{"rendered":"<p>This plugin logs the activity of supported plugins to a file, making it easier to figure out why there\u2019s a problem.<\/p>\n<p>If you have been asked to install this plugin because of a support issue then installing this plugin is just like installing any other plugin. Once installed, go to Settings->WP Logger and enable logging. If you have a number of supported plugins enable the one you are interested in.<\/p>\n<p>Developers who want to use this plugin to add logging to their own plugin should see the Developers section of this documentation.<\/p>\n<p>Mark Jaquith\u2019s <a href=\"https:\/\/wordpress.org\/extend\/plugins\/monitor-pages\/\" rel=\"ugc\">Monitor Pages<\/a> plugin was used as a template for this plugin. Thanks Mark!<\/p>\n<h4>Developers<\/h4>\n<p>Other plugins can use this plugin to record important events which are then dumped to a log file. Plugins must add the event to a global array in the following way:<\/p>\n<pre><code>$GLOBALS[ 'wp_log' ][ 'name_of_plugin' ][] = 'Some important event';\n<\/code><\/pre>\n<p>Plugins must also add themselves to a list of enabled plugins. This will make it easier for blog owners to filter out which plugin they want to debug on the settings page. Add and edit the following code so it is executed when the plugin is loaded.<\/p>\n<pre><code>$GLOBALS[ 'wp_log_plugins' ][] = 'name_of_plugin';\n<\/code><\/pre>\n<p>A hypothetical example might be a plugin (let\u2019s call it \u201cBig A\u201d) that uses the output buffer to change the letter \u201ca\u201d to \u201cA\u201d. The events recorded by this might include the following:<\/p>\n<pre><code>$GLOBALS[ 'wp_log' ][ 'big_a' ][] = 'Created output buffer';\n$GLOBALS[ 'wp_log' ][ 'big_a' ][] = 'Output buffer callback';\n$GLOBALS[ 'wp_log' ][ 'big_a' ][] = 'Replaced a with A in page';\n<\/code><\/pre>\n<p>This plugin takes the \u201cwp_log\u201d array and dumps it to a file in the upload directory of the blog it\u2019s activated on. The file is linked from the plugin settings page and can be deleted on that page too. The file is a simple text file and is not protected in any way so be careful if auth cookies are logged by a plugin.<\/p>\n<p>A \u201clog\u201d function isn\u2019t included but if you want to add one to your plugin check the constant WP_DEBUG_LOG is defined before adding to the log array. If your plugin doesn\u2019t use a class make sure that you call the log function a unique name so it doesn\u2019t conflict with other plugins.<\/p>\n<pre><code>function log( $message ) {\n    if ( defined( 'WP_DEBUG_LOG' ) )\n        $GLOBALS[ 'wp_log' ][ 'name_of_plugin' ][] = $message;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A plugin that makes it easy to log code activity to a file.<\/p>\n","protected":false},"author":65,"featured_media":228505,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"WP Debug Logger - \u8587\u6653\u6735\u63d2\u4ef6\u76ee\u5f55","description":"A plugin that makes it easy to log code activity to a file."},"footnotes":""},"categories":[1],"tags":[7,282,424,257],"class_list":["post-205607","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-debug","tag-development","tag-log","tag-php"],"_links":{"self":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/205607","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/comments?post=205607"}],"version-history":[{"count":0,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/posts\/205607\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media\/228505"}],"wp:attachment":[{"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/media?parent=205607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/categories?post=205607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.weixiaoduo.com\/plugins\/wp-json\/wp\/v2\/tags?post=205607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}