[wp-trac] [WordPress Trac] #27984: Log Plugin Activation Output in Debug.log if WP_DEBUG_LOG is enabled

WordPress Trac noreply at wordpress.org
Wed Apr 23 01:36:09 UTC 2014


#27984: Log Plugin Activation Output in Debug.log if WP_DEBUG_LOG is enabled
-----------------------------+-----------------------------
 Reporter:  lordspace        |      Owner:
     Type:  feature request  |     Status:  new
 Priority:  normal           |  Milestone:  Awaiting Review
Component:  Plugins          |    Version:  trunk
 Severity:  normal           |   Keywords:
  Focuses:                   |
-----------------------------+-----------------------------
 I just found out that one of my plugins was producing some output but I
 couldn't find it in the logs.
 I dug deeper and noticed that WordPress starts the output buffering and
 then loads the plugin file but it doesn't do anything with the output
 except for it checks for its size.

 That's in /wp-admin/includes/plugin.php around line 601

 This code allowed me to log the errors (installed it as an MU plugin).

 {{{
 add_action('activated_plugin', 'dbg_log_error', 0, 2);

 function dbg_log_error($plugin, $network_wide) {
         if (ob_get_length() == 0) {
                 return ;
         }

         $buff = '';
         $buff .= "Plugin: $plugin\n";
         $buff .= sprintf("Network Wide: %s\n", $network_wide ? 'No' :
 'Yes');
         $buff .= "Output:\n";
         $buff .= ob_get_contents() . "\n\n";

         file_put_contents(WP_CONTENT_DIR. '/plugin_activation_error.log',
 $buff, FILE_APPEND);
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27984>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list