log( $level, $message, array( 'source' => self::SOURCE ) ); } /** * Recursively replace sensitive values with a fixed mask. * * @param array $data Arbitrary context array. * @return array */ private static function redact( $data ) { $out = array(); foreach ( $data as $key => $value ) { if ( is_array( $value ) ) { $out[ $key ] = self::redact( $value ); continue; } if ( in_array( strtolower( (string) $key ), self::$sensitive_keys, true ) ) { $out[ $key ] = '***'; continue; } $out[ $key ] = $value; } return $out; } }