WC_Logger::__construct()
Constructor for the logger.
Метод класса: WC_Logger{}
Хуки из метода
Возвращает
null
. Ничего (null).
Использование
$WC_Logger = new WC_Logger(); $WC_Logger->__construct( $handlers, $threshold );
- $handlers(массив)
- Array of log handlers. If $handlers is not provided, the filter woocommerce_register_log_handlers be used to define the handlers. If $handlers is provided, the filter will not be applied and the handlers will be used directly.
По умолчанию: null - $threshold(строка)
- Define an explicit threshold. May be configured via WC_LOG_THRESHOLD. By default, all logs will be processed.
По умолчанию: null
Код WC_Logger::__construct() WC Logger:: construct WC 8.7.0
public function __construct( $handlers = null, $threshold = null ) { if ( null === $handlers ) { $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 ) ); } $register_handlers = array(); if ( ! empty( $handlers ) && is_array( $handlers ) ) { foreach ( $handlers as $handler ) { if ( $handler instanceof WC_Log_Handler_Interface ) { $register_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' ); } } } if ( ! WC_Log_Levels::is_valid_level( $threshold ) ) { $threshold = LoggingUtil::get_level_threshold(); } $this->handlers = $register_handlers; $this->threshold = WC_Log_Levels::get_level_severity( $threshold ); }