<commit_before>require 'vmdb/loggers'

module Vmdb
  class LogProxy < Struct.new(:klass, :separator, :prefix_cache)
    LEVELS = [:debug, :info, :warn, :error]

    # def debug?
    # def info?
    # def warn?
    # def error?
    # def log_backtrace
    # def level
    (LEVELS.map { |l| :"#{l}?" } + [:log_backtrace, :level]).each do |method|
      define_method(method) { |*args| logger.send(method, *args) }
    end

    LEVELS.each do |level|
      define_method(level) do |msg = nil, &blk|
        location = caller_locations(1, 1)
        if blk
          logger.send(level) do
            "#{prefix(location)} #{blk.call}"
          end
        else
          logger.send(level, "#{prefix(location)} #{msg}")
        end
      end
    end
<commit_msg>Expose the add method via Vmdb::LogProxy<commit_after>require 'vmdb/loggers'

module Vmdb
  class LogProxy < Struct.new(:klass, :separator, :prefix_cache)
    LEVELS = [:debug, :info, :warn, :error]

    # def debug?
    # def info?
    # def warn?
    # def error?
    # def add
    # def level
    # def log_backtrace
    (LEVELS.map { |l| :"#{l}?" } + %i[add level log_backtrace]).each do |method|
      define_method(method) { |*args| logger.send(method, *args) }
    end

    LEVELS.each do |level|
      define_method(level) do |msg = nil, &blk|
        location = caller_locations(1, 1)
        if blk
          logger.send(level) do
            "#{prefix(location)} #{blk.call}"
          end
        else
          logger.send(level, "#{prefix(location)} #{msg}")
        end
      end
    end

{'fraction_non_alphanumeric': 0.1440460947503201, 'fraction_numerical': 0.002560819462227913, 'mean_word_length': 2.325531914893617, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3055936', 'n_tokens_mistral': 549, 'n_tokens_neox': 536, 'n_words': 134}