$context Context, redacted before logging. * @return void */ public static function log( $level, $message, array $context = array() ) { if ( ! function_exists( 'wc_get_logger' ) ) { return; } $context = self::redact( $context ); $context['source'] = self::SOURCE; wc_get_logger()->log( $level, $message, $context ); } /** * Info shortcut. * * @param string $message Message. * @param array $context Context. * @return void */ public static function info( $message, array $context = array() ) { self::log( 'info', $message, $context ); } /** * Warning shortcut. * * @param string $message Message. * @param array $context Context. * @return void */ public static function warning( $message, array $context = array() ) { self::log( 'warning', $message, $context ); } /** * Error shortcut. * * @param string $message Message. * @param array $context Context. * @return void */ public static function error( $message, array $context = array() ) { self::log( 'error', $message, $context ); } /** * Replaces sensitive values recursively. * * @param array $context Context. * @return array */ public static function redact( array $context ) { foreach ( $context as $key => $value ) { if ( is_array( $value ) ) { $context[ $key ] = self::redact( $value ); continue; } foreach ( self::$redact_patterns as $pattern ) { if ( false !== stripos( (string) $key, $pattern ) ) { $context[ $key ] = '[redacted]'; break; } } } return $context; } }