<commit_before>﻿using System;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using KafkaNet.Model;
using KafkaNet.Protocol;

namespace KafkaNet
{
    public class DefaultKafkaConnectionFactory : IKafkaConnectionFactory
    {
        public IKafkaConnection Create(Uri kafkaAddress, int responseTimeoutMs, IKafkaLog log)
        {
            return new KafkaConnection(new KafkaTcpSocket(log, Resolve(kafkaAddress, log)), responseTimeoutMs, log);
        }

        public KafkaEndpoint Resolve(Uri kafkaAddress, IKafkaLog log)
        {
            var ipAddress = GetFirstAddress(kafkaAddress.Host, log);
            var ipEndpoint = new IPEndPoint(ipAddress, kafkaAddress.Port);

            var kafkaEndpoint = new KafkaEndpoint()
            {
                ServeUri = kafkaAddress,
                Endpoint = ipEndpoint
            };

            return kafkaEndpoint;
        }


        private static IPAddress GetFirstAddress(string hostname, IKafkaLog log)
        {
            //lookup the IP address from the provided host name
            var addresses = Dns.GetHostAddresses(hostname);

            if (addresses.Length > 0)
            {
                Array.ForEach(addresses, address => log.DebugFormat("Found address {0} for {1}", addresses, hostname));

                var selectedAddress = addresses.FirstOrDefault(item => item.AddressFamily == AddressFamily.InterNetwork) ?? addresses.First();

                log.DebugFormat("Using address {0} for {1}", selectedAddress, hostname);

                return selectedAddress;
            }

            throw new UnresolvedHostnameException("Could not resolve the following hostname: {0}", hostname);
        }
    }<commit_msg>Fix debug output<commit_after>﻿using System;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using KafkaNet.Model;
using KafkaNet.Protocol;

namespace KafkaNet
{
    public class DefaultKafkaConnectionFactory : IKafkaConnectionFactory
    {
        public IKafkaConnection Create(Uri kafkaAddress, int responseTimeoutMs, IKafkaLog log)
        {
            return new KafkaConnection(new KafkaTcpSocket(log, Resolve(kafkaAddress, log)), responseTimeoutMs, log);
        }

        public KafkaEndpoint Resolve(Uri kafkaAddress, IKafkaLog log)
        {
            var ipAddress = GetFirstAddress(kafkaAddress.Host, log);
            var ipEndpoint = new IPEndPoint(ipAddress, kafkaAddress.Port);

            var kafkaEndpoint = new KafkaEndpoint()
            {
                ServeUri = kafkaAddress,
                Endpoint = ipEndpoint
            };

            return kafkaEndpoint;
        }


        private static IPAddress GetFirstAddress(string hostname, IKafkaLog log)
        {
            //lookup the IP address from the provided host name
            var addresses = Dns.GetHostAddresses(hostname);

            if (addresses.Length > 0)
            {
                Array.ForEach(addresses, address => log.DebugFormat("Found address {0} for {1}", address, hostname));

                var selectedAddress = addresses.FirstOrDefault(item => item.AddressFamily == AddressFamily.InterNetwork) ?? addresses.First();

                log.DebugFormat("Using address {0} for {1}", selectedAddress, hostname);

                return selectedAddress;
            }

            throw new UnresolvedHostnameException("Could not resolve the following hostname: {0}", hostname);
        }
    }
{'fraction_non_alphanumeric': 0.0801626488527447, 'fraction_numerical': 0.0034853325588149867, 'mean_word_length': 2.393103448275862, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3135185', 'n_tokens_mistral': 899, 'n_tokens_neox': 865, 'n_words': 232}