<commit_before><?php

require_once(dirname(__FILE__) . "/LogMessage.php");

class Logger {
	
	const ERROR=1;
	const WARNING=2;
	const WARN=2;
	const INFO=3;
	const INFO_2=4;
	const INFO_3=5;
	
	private $consumers = array();
	private $fields = array();
	
	private function process($logMessage) {
		foreach ($this->consumers as $consumer)
			$consumer->process($this, $logMessage);
	}
	
	public function message($tags, $level, $text) {
		$f = array();
		foreach ($this->fields as $key=>$valuefunc)
			$f[$key] = $valuefunc($this, $tags, $level, $text);
		$this->process(new LogMessage($tags, $level, $text, $f));
	}
	
	public function registerConsumer($consumer) {
		$this->consumers[] = $consumer;
	}
	
	public function registerField($key, $valuefunc) {
		$this->fields[$key] = $valuefunc;
	}
	
}
<commit_msg>Logger Field allows values instead of callables<commit_after><?php

require_once(dirname(__FILE__) . "/LogMessage.php");

class Logger {
	
	const ERROR=1;
	const WARNING=2;
	const WARN=2;
	const INFO=3;
	const INFO_2=4;
	const INFO_3=5;
	
	private $consumers = array();
	private $fields = array();
	
	private function process($logMessage) {
		foreach ($this->consumers as $consumer)
			$consumer->process($this, $logMessage);
	}
	
	public function message($tags, $level, $text) {
		$f = array();
		foreach ($this->fields as $key=>$valuefunc)
			$f[$key] = is_callable($value_func) ? $valuefunc($this, $tags, $level, $text) : $valuefunc;
		$this->process(new LogMessage($tags, $level, $text, $f));
	}
	
	public function registerConsumer($consumer) {
		$this->consumers[] = $consumer;
	}
	
	public function registerField($key, $valuefunc) {
		$this->fields[$key] = $valuefunc;
	}
	
}

{'fraction_non_alphanumeric': 0.16439909297052155, 'fraction_numerical': 0.009070294784580499, 'mean_word_length': 3.835616438356164, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '872933', 'n_tokens_mistral': 655, 'n_tokens_neox': 595, 'n_words': 136}