<commit_before>require 'tumugi/logger/logger'
require 'forwardable'

module Tumugi
  class ScopedLogger
    extend Forwardable
    def_delegators :@logger, :debug?, :error?, :fatal?, :info?, :warn?, :level

    def initialize(scope)
      @scope = scope
      @logger = Tumugi::Logger.instance
    end

    [:debug, :errror, :fatal, :info, :warn].each do |level|
      class_eval "def #{level}(msg=nil, &block); log(:#{level}, msg, &block) end", __FILE__, __LINE__
    end

    def trace(msg=nil, &block)
      if ENV.key?("TUMUGI_DEBUG")
        log(:debug, msg, &block)
      end
    end

    private

    def log(level, msg=nil, &block)
      if block_given?
        @logger.send(level, "#{@scope}", &block)
      else
        @logger.send(level, "#{@scope}") { msg }
      end
    end
  end
end<commit_msg>Add delgationm method to Logger<commit_after>require 'tumugi/logger/logger'
require 'forwardable'

module Tumugi
  class ScopedLogger
    extend Forwardable
    def_delegators :@logger, :init, :verbose!, :quiet!, :workflow_id, :workflow_id=,
                             :debug?, :error?, :fatal?, :info?, :warn?, :level

    def initialize(scope)
      @scope = scope
      @logger = Tumugi::Logger.instance
    end

    [:debug, :errror, :fatal, :info, :warn].each do |level|
      class_eval "def #{level}(msg=nil, &block); log(:#{level}, msg, &block) end", __FILE__, __LINE__
    end

    def trace(msg=nil, &block)
      if ENV.key?("TUMUGI_DEBUG")
        log(:debug, msg, &block)
      end
    end

    private

    def log(level, msg=nil, &block)
      if block_given?
        @logger.send(level, "#{@scope}", &block)
      else
        @logger.send(level, "#{@scope}") { msg }
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.15031921067904816, 'fraction_numerical': 0.0, 'mean_word_length': 2.8057395143487858, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4132523', 'n_tokens_mistral': 610, 'n_tokens_neox': 586, 'n_words': 150}