<commit_before>require 'logging'

module Adhearsion
  module Logging

    LOG_LEVELS = %w(TRACE DEBUG INFO WARN ERROR FATAL)

    METHOD = :logger

    class << self

      ::Logging.color_scheme 'bright',
        :levels => {
          :info  => :green,
          :warn  => :yellow,
          :error => :red,
          :fatal => [:white, :on_red]
        },
        :date     => :blue,
        :logger   => :cyan,
        :message  => :magenta

      def adhearsion_pattern
        '[%d] %-5l %c: %m\n'
      end

      def silence!
        self.logging_level = :fatal
      end

      def unsilence!
        self.logging_level = :info
      end

      def reset
        ::Logging.reset
      end

      def init
        ::Logging.init LOG_LEVELS

        LOG_LEVELS.each do |level|
          Adhearsion::Logging.const_defined?(level) or Adhearsion::Logging.const_set(level, ::Logging::LEVELS[::Logging.levelify(level)])
        end
      end

      def start(_appenders = nil, level = :info, formatter = nil)
        ::Logging.logger.root.appenders = _appenders.nil? ? default_appenders : _appenders

        ::Logging.logger.root.level = level

        formatter = formatter if formatter
      end

      def default_appenders
        [::Logging.appenders.stdout(
           'stdout',
           :layout => ::Logging.layouts.pattern(
             :pattern => adhearsion_pattern,<commit_msg>[BUG] #unsilence! should restore the configured log level<commit_after>require 'logging'

module Adhearsion
  module Logging

    LOG_LEVELS = %w(TRACE DEBUG INFO WARN ERROR FATAL)

    METHOD = :logger

    class << self

      ::Logging.color_scheme 'bright',
        :levels => {
          :info  => :green,
          :warn  => :yellow,
          :error => :red,
          :fatal => [:white, :on_red]
        },
        :date     => :blue,
        :logger   => :cyan,
        :message  => :magenta

      def adhearsion_pattern
        '[%d] %-5l %c: %m\n'
      end

      def silence!
        self.logging_level = :fatal
      end

      def unsilence!
        self.logging_level = Adhearsion.config.platform.logging['level']
      end

      def reset
        ::Logging.reset
      end

      def init
        ::Logging.init LOG_LEVELS

        LOG_LEVELS.each do |level|
          Adhearsion::Logging.const_defined?(level) or Adhearsion::Logging.const_set(level, ::Logging::LEVELS[::Logging.levelify(level)])
        end
      end

      def start(_appenders = nil, level = :info, formatter = nil)
        ::Logging.logger.root.appenders = _appenders.nil? ? default_appenders : _appenders

        ::Logging.logger.root.level = level

        formatter = formatter if formatter
      end

      def default_appenders
        [::Logging.appenders.stdout(
           'stdout',
           :layout => ::Logging.layouts.pattern(
             :pattern => adhearsion_pattern,
{'fraction_non_alphanumeric': 0.11436541143654114, 'fraction_numerical': 0.000697350069735007, 'mean_word_length': 1.9792315680166148, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '3483275', 'n_tokens_mistral': 929, 'n_tokens_neox': 887, 'n_words': 196}