Skip to content

Commit

Permalink
Update the logger example in the docs to use the 'satispress_compose'…
Browse files Browse the repository at this point in the history
… action.
  • Loading branch information
bradyvercher committed Aug 22, 2018
1 parent 1f3e091 commit 422c3dd
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions docs/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,17 @@ use Monolog\Handler\ErrorLogHandler;
use Monolog\Processor\PsrLogMessageProcessor;

/**
* Register the logger before SatisPress is configured.
* Register the logger before SatisPress is composed.
*/
add_action( 'plugins_loaded', function() {
// Bail if SatisPress isn't loaded.
if ( ! function_exists( '\SatisPress\plugin' ) ) {
return;
}

// Retrieve the container.
$container = \SatisPress\plugin()->get_container();

// Register a custom logger.
add_action( 'satispress_compose', function( $plugin, $container ) {
$container['logger'] = function() {
$logger = new Logger( 'satispress' );
$logger->pushHandler( new ErrorLogHandler( ErrorLogHandler::OPERATING_SYSTEM, LOGGER::WARNING ) );
$logger->pushProcessor( new PsrLogMessageProcessor );

return $logger;
};
}, 1 );
}, 10, 2 );
```

_Monolog should be required with Composer and the autoloader needs to be included before using it in your project._
Expand Down

0 comments on commit 422c3dd

Please sign in to comment.