WordPress.org

Ready to get started?Download WordPress

Plugin Directory

!This plugin hasn't been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

WordPress Logger

Display log messages during plugin and theme development on the console in Safari and Firefox (with Firebug) browsers.

Installing from the Admin Panel

  1. Select the Add New subpanel from the Plugins panel.
  2. Type in "wordpress-logger" in the search field and click the Search button.
  3. Identify the "WordPress Logger" from the plugin list and click on its install action.
  4. Click on the Install Now button in the resulting dialog.
  5. Click on the Activate Plugin link.

Installing manually

  1. Verify that you have PHP5, which is required for this plugin.
  2. Upload the whole wordpress-logger folder into the /wp-content/plugins/ directory.
  3. Activate the plugin through the Plugins panel in WordPress.

Requirements

  • Make sure that your theme template has a footer ( index.php should have a get_footer() function call at the end).
  • Turn on the console in your browser:
    • Firefox: The Firebug extension needs to be installed and activated.
    • Safari: Show the Error Console from the Debug/Develop menu. See FAQ section for details on how to enable the Debug menu.

Usage

After activating the plugin, the following PHP function call can log any PHP expression to the console log.

     $wplogger->log( php_expression [, message_type] );

The message_type is optional and can be any one of the following constants:

  • WPLOG_ERR
  • WPLOG_WARNING
  • WPLOG_INFO
  • WPLOG_DEBUG

Examples

Logging from template files - inside the loop to display post IDs.

    <?php $wplogger->log( 'Post ID: '.$post->ID ); ?>

    Output:

    [Information: from line 20 in file index.php] Post ID: 125
    [Information: from line 20 in file index.php] Post ID: 116
    [Information: from line 20 in file index.php] Post ID: 65

Logging from PHP files (e.g. functions.php) ( always a good idea to check if $wplogger is available ). Note the message type set to warning through the second parameter.

    if ($wplogger) $wplogger->log( get_option('active_plugins'), WPLOG_WARNING );

    Output:

    [Warning: from line 55 in file functions.php] array (
          0 => 'wplogger/wplogger.php',
          1 => '12seconds-widget/12seconds-widget.php',
          2 => 'get-the-image/get-the-image.php',
    )

Logging from plugins - inside a plugin function. Note the global statement to get $wplogger into current scope.

    global $wplogger; $wplogger->log( 'No images attached to this post', WPLOG_ERR );

    Output:

    [Error: from line 206 in file get-the-image.php] No images attached to this post

Requires: 2.5 or higher
Compatible up to: 2.7.1
Last Updated: 2009-5-18
Downloads: 1,742

Ratings

5 stars
5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

0,1,0
0,1,0
100,1,1
0,1,0