<commit_before>package nl.idgis.publisher.utils;

import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.mock;

import org.mockito.stubbing.Answer;

import akka.event.LoggingAdapter;

public class Logging {
	
	private static void println(String level, Object[] args) {
		String message = args[0].toString();
		for(int i = 1; i < args.length; i++) {
			message = message.replaceFirst("\\{\\}", args[i].toString());
		}
		
		System.out.println("[" + level + "] [test] " + message);
	}

	public static LoggingAdapter getLogger() {
		LoggingAdapter log = mock(LoggingAdapter.class);
		
		Answer<Void> debugAnswer = invocation -> {
			println("DEBUG", invocation.getArguments());
			return null;
		};
		doAnswer(debugAnswer).when(log).debug(anyString());
		doAnswer(debugAnswer).when(log).debug(anyString(), anyObject());
		doAnswer(debugAnswer).when(log).debug(anyString(), anyObject(), anyObject());
		doAnswer(debugAnswer).when(log).debug(anyString(), anyObject(), anyObject(), anyObject());
		doAnswer(debugAnswer).when(log).debug(anyString(), anyObject(), anyObject(), anyObject(), anyObject());
		
		Answer<Void> warningAnswer = invocation -> {
			println("WARNING", invocation.getArguments());
			return null;
		};		
		doAnswer(warningAnswer).when(log).warning(anyString());
		doAnswer(warningAnswer).when(log).warning(anyString(), anyObject());
		doAnswer(warningAnswer).when(log).warning(anyString(), anyObject(), anyObject());
		doAnswer(warningAnswer).when(log).warning(anyString(), anyObject(), anyObject(), anyObject());
		doAnswer(warningAnswer).when(log).warning(anyString(), anyObject(), anyObject(), anyObject(), anyObject());
		
		Answer<Void> infoAnswer = invocation -> {<commit_msg>NPE fixed<commit_after>package nl.idgis.publisher.utils;

import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.mock;

import org.mockito.stubbing.Answer;

import akka.event.LoggingAdapter;

public class Logging {
	
	private static void println(String level, Object[] args) {
		String message = args[0].toString();
		for(int i = 1; i < args.length; i++) {
			Object o = args[i];			
			message = message.replaceFirst("\\{\\}", o == null ? "null" : o.toString());
		}
		
		System.out.println("[" + level + "] [test] " + message);
	}

	public static LoggingAdapter getLogger() {
		LoggingAdapter log = mock(LoggingAdapter.class);
		
		Answer<Void> debugAnswer = invocation -> {
			println("DEBUG", invocation.getArguments());
			return null;
		};
		doAnswer(debugAnswer).when(log).debug(anyString());
		doAnswer(debugAnswer).when(log).debug(anyString(), anyObject());
		doAnswer(debugAnswer).when(log).debug(anyString(), anyObject(), anyObject());
		doAnswer(debugAnswer).when(log).debug(anyString(), anyObject(), anyObject(), anyObject());
		doAnswer(debugAnswer).when(log).debug(anyString(), anyObject(), anyObject(), anyObject(), anyObject());
		
		Answer<Void> warningAnswer = invocation -> {
			println("WARNING", invocation.getArguments());
			return null;
		};		
		doAnswer(warningAnswer).when(log).warning(anyString());
		doAnswer(warningAnswer).when(log).warning(anyString(), anyObject());
		doAnswer(warningAnswer).when(log).warning(anyString(), anyObject(), anyObject());
		doAnswer(warningAnswer).when(log).warning(anyString(), anyObject(), anyObject(), anyObject());
		doAnswer(warningAnswer).when(log).warning(anyString(), anyObject(), anyObject(), anyObject(), anyObject());
		
		Answer<Void> infoAnswer = invocation -> {
{'fraction_non_alphanumeric': 0.1688006271230729, 'fraction_numerical': 0.0010452051215050953, 'mean_word_length': 5.835714285714285, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '2497005', 'n_tokens_mistral': 1297, 'n_tokens_neox': 1142, 'n_words': 215}