Display log messages during plugin and theme development on the console in Safari and Firefox (with Firebug) browsers.
Installing from the Admin Panel
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:
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