From 422c3dd78e38f683a7cb9f25453c71c50f8b5a08 Mon Sep 17 00:00:00 2001 From: Brady Vercher Date: Wed, 22 Aug 2018 14:48:40 -0700 Subject: [PATCH] Update the logger example in the docs to use the 'satispress_compose' action. --- docs/logging.md | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/docs/logging.md b/docs/logging.md index 1bb4440..669de4d 100644 --- a/docs/logging.md +++ b/docs/logging.md @@ -13,18 +13,9 @@ 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 ) ); @@ -32,7 +23,7 @@ add_action( 'plugins_loaded', function() { return $logger; }; -}, 1 ); +}, 10, 2 ); ``` _Monolog should be required with Composer and the autoloader needs to be included before using it in your project._