<commit_before>require 'logger'
require 'forwardable'
require 'thread'
require 'term/ansicolor'
require 'time'

module Mamiya
  class Logger
    include ::Logger::Severity
    extend Forwardable

    def self.defaults
      return @defaults if @defaults
      if ENV["MAMIYA_LOG_LEVEL"]
        level = ::Logger::Severity.const_get(ENV["MAMIYA_LOG_LEVEL"].upcase) rescue INFO
      else
        level = INFO
      end
      @defaults = {color: nil, outputs: [STDOUT], level: level}
    end

    def initialize(color: self.class.defaults[:color], outputs: self.class.defaults[:outputs], level: self.class.defaults[:level])
      @logdev = LogDev.new(outputs)
      @logger = ::Logger.new(@logdev)
      @logger.level = level
      @logger.formatter = method(:format)

      @color = color.nil? ? @logdev.tty? : color
    end

    attr_accessor :color
    def_delegators :@logger,
      :<<, :add, :log,
      :fatal, :error, :warn, :info, :debug,
      :level, :level=, :progname, :progname=,
      :close

    def add_output(*outputs)
      @logdev.add(*outputs)
    end

    def remove_output(*outputs)
      @logdev.remove(*outputs)
    end

    def with_additional_file(*outputs)
      @logdev.add_output(*outputs)

      yield

    ensure<commit_msg>Delegate #*? methods to Logger<commit_after>require 'logger'
require 'forwardable'
require 'thread'
require 'term/ansicolor'
require 'time'

module Mamiya
  class Logger
    include ::Logger::Severity
    extend Forwardable

    def self.defaults
      return @defaults if @defaults
      if ENV["MAMIYA_LOG_LEVEL"]
        level = ::Logger::Severity.const_get(ENV["MAMIYA_LOG_LEVEL"].upcase) rescue INFO
      else
        level = INFO
      end
      @defaults = {color: nil, outputs: [STDOUT], level: level}
    end

    def initialize(color: self.class.defaults[:color], outputs: self.class.defaults[:outputs], level: self.class.defaults[:level])
      @logdev = LogDev.new(outputs)
      @logger = ::Logger.new(@logdev)
      @logger.level = level
      @logger.formatter = method(:format)

      @color = color.nil? ? @logdev.tty? : color
    end

    attr_accessor :color
    def_delegators :@logger,
      :<<, :add, :log,
      :fatal, :error, :warn, :info, :debug,
      :fatal?, :error?, :warn?, :info?, :debug?,
      :level, :level=, :progname, :progname=,
      :close

    def add_output(*outputs)
      @logdev.add(*outputs)
    end

    def remove_output(*outputs)
      @logdev.remove(*outputs)
    end

    def with_additional_file(*outputs)
      @logdev.add_output(*outputs)

      yield

    ensure
{'fraction_non_alphanumeric': 0.13131313131313133, 'fraction_numerical': 0.0, 'mean_word_length': 3.0234375, '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': '4585006', 'n_tokens_mistral': 851, 'n_tokens_neox': 817, 'n_words': 189}