Add filter for enabling logging

This commit is contained in:
Alex P 2022-03-29 14:04:43 +03:00
parent 6ee900cb01
commit be55fcf711
2 changed files with 13 additions and 2 deletions

View file

@ -88,8 +88,7 @@ return array(
);
},
'woocommerce.logger.woocommerce' => function ( ContainerInterface $container ): LoggerInterface {
$settings = $container->get( 'wcgateway.settings' );
if ( ! function_exists( 'wc_get_logger' ) || ! $settings->has( 'logging_enabled' ) || ! $settings->get( 'logging_enabled' ) ) {
if ( ! function_exists( 'wc_get_logger' ) || ! $container->get( 'wcgateway.logging.is-enabled' ) ) {
return new NullLogger();
}

View file

@ -2129,4 +2129,16 @@ return array(
$container->get( 'wcgateway.settings' )
);
},
'wcgateway.logging.is-enabled' => function ( ContainerInterface $container ) : bool {
$settings = $container->get( 'wcgateway.settings' );
/**
* Whether the logging of the plugin errors/events is enabled.
*/
return apply_filters(
'woocommerce_paypal_payments_is_logging_enabled',
$settings->has( 'logging_enabled' ) && $settings->get( 'logging_enabled' )
);
},
);