<commit_before>package acracensor

import log "github.com/sirupsen/logrus"

type AcraCensor struct {
	handlers []QueryHandlerInterface

}

func (acraCensor *AcraCensor) AddHandler(handler QueryHandlerInterface) {
	acraCensor.handlers = append(acraCensor.handlers, handler)
}

func (acraCensor *AcraCensor) RemoveHandler(handler QueryHandlerInterface) {
	for index, handlerFromRange := range acraCensor.handlers {
		if handlerFromRange == handler {
			acraCensor.handlers = append(acraCensor.handlers[:index], acraCensor.handlers[index+1:]...)
		}
	}
}

func (acraCensor *AcraCensor) HandleQuery(query string) error {
	for _, handler := range acraCensor.handlers {
		if err := handler.CheckQuery(query); err != nil {
			return err
		}
	}
	log.Infof("Acra' censor passed")
	return nil
}<commit_msg>Add raw query string to main log stream<commit_after>package acracensor

import log "github.com/sirupsen/logrus"

type AcraCensor struct {
	handlers []QueryHandlerInterface

}

func (acraCensor *AcraCensor) AddHandler(handler QueryHandlerInterface) {
	acraCensor.handlers = append(acraCensor.handlers, handler)
}

func (acraCensor *AcraCensor) RemoveHandler(handler QueryHandlerInterface) {
	for index, handlerFromRange := range acraCensor.handlers {
		if handlerFromRange == handler {
			acraCensor.handlers = append(acraCensor.handlers[:index], acraCensor.handlers[index+1:]...)
		}
	}
}

func (acraCensor *AcraCensor) HandleQuery(query string) error {
	for _, handler := range acraCensor.handlers {
		if err := handler.CheckQuery(query); err != nil {
			log.Errorf("Forbidden query: '%s'", query)
			return err
		}
	}
	log.Infof("Allowed query: '%s'", query)
	return nil
}
{'fraction_non_alphanumeric': 0.11370436864153202, 'fraction_numerical': 0.0011968880909634949, 'mean_word_length': 5.406130268199234, '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': '4426198', 'n_tokens_mistral': 588, 'n_tokens_neox': 570, 'n_words': 124}