<commit_before># encoding: utf-8

module Ktl
  class Command < Thor

    java_import 'java.io.ByteArrayOutputStream'

    private

    def with_zk_client
      zk_client = ZookeeperClient.new(options.zookeeper).setup
      yield zk_client
    rescue => e
      say 'Error: %s (%s)' % [e.message, e.class.name], :red
      say e.backtrace.join($/)
    ensure
      zk_client.close if zk_client
    end

    def with_kafka_client(options={})
      brokers = with_zk_client { |zk_client| ScalaEnumerable.new(zk_client.brokers).map(&:connection_string) }
      kafka_client = KafkaClient.create(options.merge(hosts: brokers))
      yield kafka_client
    ensure
      kafka_client.close if kafka_client
    end
<commit_msg>Update error logging in Command <commit_after># encoding: utf-8

module Ktl
  class Command < Thor

    java_import 'java.io.ByteArrayOutputStream'

    private

    def with_zk_client
      zk_client = ZookeeperClient.new(options.zookeeper).setup
      yield zk_client
    rescue => e
      logger.error '%s (%s)' % [e.message, e.class.name]
      logger.debug e.backtrace.join($/)
    ensure
      zk_client.close if zk_client
    end

    def with_kafka_client(options={})
      brokers = with_zk_client { |zk_client| ScalaEnumerable.new(zk_client.brokers).map(&:connection_string) }
      kafka_client = KafkaClient.create(options.merge(hosts: brokers))
      yield kafka_client
    ensure
      kafka_client.close if kafka_client
    end

{'fraction_non_alphanumeric': 0.09507523939808482, 'fraction_numerical': 0.0013679890560875513, 'mean_word_length': 3.15625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '187821', 'n_tokens_mistral': 490, 'n_tokens_neox': 473, 'n_words': 101}