<commit_before>package dk.braintrust.os.logger;

import java.io.IOException;
import java.net.URI;
import java.util.LinkedList;
import java.util.List;

import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;

import com.couchbase.client.CouchbaseClient;

/**
 * @author <NAME> (<EMAIL>)
 * 
 */
public class CouchBaseLogAppender extends AppenderSkeleton {
	private String hosts = "localhost";
	private int port = 8092;
	private String password = "";
	private String defaultMetadataBucket = "default";
	private Boolean developmentMode = true;
	private int eviction = 0;
	private CouchbaseClient client = null;
	private static List<URI> uris = new LinkedList<URI>();

	// private Map<String, String> messages; //TODO: store the log object into a
	// temp memtable..
	
	@Override
	public void activateOptions() {
		super.activateOptions();
		try {
			client = setupCouchbase();
		} catch (IOException e) {
			e.printStackTrace();
		}
		// TODO: setup mem queue here..

	}

	private CouchbaseClient setupCouchbase() throws IOException {
		if (developmentMode)
			System.setProperty("viewmode", "development");

		String[] couchServers = hosts.split(",");
		for (String srv : couchServers) {
			uris.add(URI.create("http://" + srv + ":" + port + "/pools"));
		}
		return new CouchbaseClient(uris, defaultMetadataBucket, password);
	}

	@Override
	protected void append(LoggingEvent event) {
		String key = "logger:" + Utils.getHostName() + "_" + event.getThreadName() + "_" + event.timeStamp;
		client.add(key, eviction, this.layout.format(event));
	}

	public void setDefaultMetadataBucket(String defaultMetadataBucket) {
		this.defaultMetadataBucket = defaultMetadataBucket;
	}

	public void setHosts(String hosts) {
		this.hosts = hosts;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public void setDevelopmentMode(Boolean developmentMode) {
		this.developmentMode = developmentMode;
	}

	public boolean requiresLayout() {
		return true;
	}

	public void close() {
		client.shutdown();
	}
}<commit_msg>Fixed little but: eviction was not set.<commit_after>package dk.braintrust.os.logger;

import java.io.IOException;
import java.net.URI;
import java.util.LinkedList;
import java.util.List;

import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;

import com.couchbase.client.CouchbaseClient;

/**
 * @author <NAME> (<EMAIL>)
 * 
 */
public class CouchBaseLogAppender extends AppenderSkeleton {
	private String hosts = "localhost";
	private int port = 8092;
	private String password = "";
	private String defaultMetadataBucket = "default";
	private boolean developmentMode = true;
	private int eviction = 0;
	private CouchbaseClient client = null;
	private static List<URI> uris = new LinkedList<URI>();

	// private Map<String, String> messages; //TODO: store the log object into a
	// temp memtable..
	
	@Override
	public void activateOptions() {
		super.activateOptions();
		try {
			client = setupCouchbase();
		} catch (IOException e) {
			e.printStackTrace();
		}
		// TODO: setup mem queue here..

	}

	private CouchbaseClient setupCouchbase() throws IOException {
		if (developmentMode)
			System.setProperty("viewmode", "development");

		String[] couchServers = hosts.split(",");
		for (String srv : couchServers) {
			uris.add(URI.create("http://" + srv + ":" + port + "/pools"));
		}
		return new CouchbaseClient(uris, defaultMetadataBucket, password);
	}

	@Override
	protected void append(LoggingEvent event) {
		String key = "logger:" + Utils.getHostName() + "_" + event.getThreadName() + "_" + event.timeStamp;
		client.add(key, eviction, this.layout.format(event));
	}

	public void setDefaultMetadataBucket(String defaultMetadataBucket) {
		this.defaultMetadataBucket = defaultMetadataBucket;
	}

	public void setHosts(String hosts) {
		this.hosts = hosts;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public void setDevelopmentMode(boolean developmentMode) {
		this.developmentMode = developmentMode;
	}
	
	public void setEviction(int eviction) {
		this.eviction = eviction;
	}

	public boolean requiresLayout() {
		return true;
	}

	public void close() {
		client.shutdown();
	}
}
{'fraction_non_alphanumeric': 0.12102351313969571, 'fraction_numerical': 0.003227293683725219, 'mean_word_length': 4.410224438902743, 'pattern_counts': {'":': 2, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7249066', 'n_tokens_mistral': 1458, 'n_tokens_neox': 1341, 'n_words': 342}