<commit_before>module CompositeLogging
  class Builder

    def initialize(logger_class = CompositeLogging::CompositeLogger, &block)
      @formatter_class = nil
      @formatter_args = {}
      @loggers = []
      
      @logger_class = logger_class
      instance_eval(&block)
    end

    def build
      logger_args = @logger_class.ancestors.include?(CompositeLogging::CompositeLogger) ? @loggers : @output_args

      logger = @logger_class.new(*logger_args)
      logger.formatter = @formatter_class.new(@formatter_args) if @formatter_class

      logger
    end

    def logger(logger_class = CompositeLogging::TaggedLogger, &block)
      @loggers << Builder.new(logger_class, &block).build
    end

    def output(*args)
      @output_args = args
    end

    def formatter(formatter_class)
      @formatter_class = formatter_class
    end

    def method_missing(name, *args, &block)
      if @formatter_class && @formatter_class.public_instance_methods.include?(:"#{name}=")
        @formatter_args[name] = args.first
      else
        super
      end
    end

  end
end<commit_msg>Allow setting logger attributes in the builder.<commit_after>module CompositeLogging
  class Builder

    def initialize(logger_class = CompositeLogging::CompositeLogger, &block)
      @formatter_class = nil
      @formatter_attrs = {}
      @loggers = []
      
      @logger_class = logger_class
      @logger_attrs = {}

      instance_eval(&block)
    end

    def build
      logger_args = @logger_class.ancestors.include?(CompositeLogging::CompositeLogger) ? @loggers : @output_args

      logger = @logger_class.new(*logger_args)
      @logger_attrs.each { |k,v| logger.send("#{k}=", v) }
      logger.formatter = @formatter_class.new(@formatter_attrs) if @formatter_class

      logger
    end

    def logger(logger_class = CompositeLogging::TaggedLogger, &block)
      @loggers << Builder.new(logger_class, &block).build
    end

    def output(*args)
      @output_args = args
    end

    def formatter(formatter_class)
      @formatter_class = formatter_class
    end

    def method_missing(name, *args, &block)
      if @formatter_class && @formatter_class.public_instance_methods.include?(:"#{name}=")
        @formatter_attrs[name] = args.first
      elsif @logger_class.public_instance_methods.include?(:"#{name}=")
        @logger_attrs[name] = args.first
      else
        super
      end
    end

  end
end
{'fraction_non_alphanumeric': 0.10243700950020652, 'fraction_numerical': 0.0, 'mean_word_length': 3.161512027491409, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '5878141', 'n_tokens_mistral': 761, 'n_tokens_neox': 728, 'n_words': 140}