WC_Logger::get_handlers()
Get an array of log handler instances.
Method of the class: WC_Logger{}
Hooks from the method
Return
WC_Log_Handler_Interface[]
.
Usage
// protected - for code of main (parent) or child class $result = $this->get_handlers();
WC_Logger::get_handlers() WC Logger::get handlers code WC 9.4.2
protected function get_handlers() { if ( ! is_null( $this->handlers ) ) { $handlers = $this->handlers; } else { $default_handler = LoggingUtil::get_default_handler(); $handler_instance = new $default_handler(); /** * Filter the list of log handler class instances that will run whenever a log entry is added. * * @param WC_Log_Handler_Interface[] * * @since 3.0.0 */ $handlers = apply_filters( 'woocommerce_register_log_handlers', array( $handler_instance ) ); } $registered_handlers = array(); if ( ! empty( $handlers ) && is_array( $handlers ) ) { foreach ( $handlers as $handler ) { if ( $handler instanceof WC_Log_Handler_Interface ) { $registered_handlers[] = $handler; } else { wc_doing_it_wrong( __METHOD__, sprintf( /* translators: 1: class name 2: WC_Log_Handler_Interface */ __( 'The provided handler %1$s does not implement %2$s.', 'woocommerce' ), '<code>' . esc_html( is_object( $handler ) ? get_class( $handler ) : $handler ) . '</code>', '<code>WC_Log_Handler_Interface</code>' ), '3.0' ); } } } return $registered_handlers; }