Plugin / WordPress Logger

Chandima Cumaranatunge

Installation

Installation

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

Ratings

0
0 reviews

Rating breakdown

Details Information

Version

0.3

First Released

12 May, 2009

Total Downloads

2,484

Wordpress Version

2.5 or higher

Tested up to:

2.7.1

Require PHP Version:

-

Tags

Contributors

This plugin has been closed.

Languages

The plugin hasn't been transalated in any language other than English.

DIRECTORY DISCLAIMER

The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.

The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.

Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.

While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.

wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.

Keep Leading Your Followers!
Share it for them.