<commit_before>/**
 * 
 */
package com.catalyst.sonar.score.log;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

/**
 * The Logger class is used for printing useful information in the console of a
 * CI engine (like Hudson/Jenkins), and for general debugging.
 * 
 * @author JDunn
 * 
 */
public class Logger {

	public static final char BORDER1 = '*';
	public static final char BORDER2 = '>';
	public static final char BORDER3 = ':';
	public static final char BORDER4 = '-';
	public static final char[] BORDER = { BORDER1, BORDER2, BORDER3, BORDER4 };
	public static final char TAB = '\t';
	public static final int BORDER_LENGTH = 70;
	public static final int TAB_LENGTH = 4;
	public static final String START = "Start ";
	public static final String END = "End ";

	public static final Logger LOG = new Logger();

	private PrintStream stream;
	private List<String> stack;

	/**
	 * The no-args constructor sets the stream to {@code System.out} and
	 * instantiates the {@code List<String> stack} as an {@link ArrayList}.
	 * {@code String}.
	 */
	public Logger() {
		this.setStream(System.out);
		this.stack = new ArrayList<String>();
	}

	/**
	 * Prints a tab for every method name in the stack List, and then prints the
	 * object.
	 * 
	 * @param x
	 * @return this
	 */
	public Logger log(Object x) {
		stream.println(tab() + x);
		return this;
	}

	/**
	 * Prints the same as {@link Logger.log(Object x)} but adding an emphasis
	 * String.
	 * 
	 * @param x
	 * @return
	 */
	public Logger logEmf(Object x) {
		stream.println(tab() + "!!! " + x);
		return log(x);
	}

	/**
	 * Prints the methodName with a border, and then adds the methodName to the
	 * stack.
	 * 
	 * @param methodName
	 * @return
	 */
	public Logger beginMethod(final String methodName) {
		String message = border(TAB_LENGTH) + START + methodName;
		stream.println(border(BORDER_LENGTH - (TAB_LENGTH * stack.size())
				- message.length()));
		stack.add(methodName);
		return this;
	}

	/**
	 * Removes the last methodName from the stack and prints it with a border.
	 * 
	 * @return
	 */
	public Logger endMethod() {
		final String methodName = stack.remove(stack.size() - 1);
		String message = border(TAB_LENGTH) + END + methodName;
		stream.println(border(BORDER_LENGTH - (TAB_LENGTH * stack.size())
				- message.length()));
		return this;
	}

	/**
	 * Returns a String to be used as a border.
	 * 
	 * @param x
	 * @return
	 */
	private String border(final int x) {
		StringBuilder border = new StringBuilder();
		for (int y = 0; y < x; y++) {
			border.append(BORDER[stack.size()]);
		}
		return border.toString();
	}

	/**
	 * Returns a String consisting of the appropriate number of tabs based on
	 * the size of the stack List.
	 * 
	 * @return
	 */
	private String tab() {
		String tabs = "";
		for (int i = 0; i < stack.size(); i++) {
			tabs += '\t';
		}
		return tabs;
	}

	/**
	 * @return the stream
	 */
	public PrintStream getStream() {
		return stream;
	}

	/**
	 * @param stream
	 *            the stream to set
	 * @param stream
	 * @return this
	 */
	public Logger setStream(PrintStream stream) {
		this.stream = stream;
		return this;
	}

}
<commit_msg>Improved methods in Logger.<commit_after>/**
 * 
 */
package com.catalyst.sonar.score.log;

import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

/**
 * The Logger class is used for printing useful information in the console of a
 * CI engine (like Hudson/Jenkins), and for general debugging.
 * 
 * @author JDunn
 * 
 */
public class Logger {

	public static final char BORDER1 = '*';
	public static final char BORDER2 = '>';
	public static final char BORDER3 = ':';
	public static final char BORDER4 = '-';
	public static final char[] BORDER = { BORDER1, BORDER2, BORDER3, BORDER4 };
	public static final char TAB = '\t';
	public static final int BORDER_LENGTH = 70;
	public static final int TAB_LENGTH = 4;
	public static final String START = "Start ";
	public static final String END = "End ";

	public static final Logger LOG = new Logger();

	private PrintStream stream;
	private List<String> stack;

	/**
	 * The no-args constructor sets the stream to {@code System.out} and
	 * instantiates the {@code List<String> stack} as an {@link ArrayList}.
	 * {@code String}.
	 */
	public Logger() {
		this.setStream(System.out);
		this.stack = new ArrayList<String>();
	}

	/**
	 * Prints a tab for every method name in the stack List, and then prints the
	 * object.
	 * 
	 * @param x
	 * @return this
	 */
	public Logger log(Object x) {
		stream.println(tab() + x);
		return this;
	}

	/**
	 * Prints the same as {@link Logger.log(Object x)} but adding an emphasis
	 * String.
	 * 
	 * @param x
	 * @return
	 */
	public Logger logEmf(Object x) {
		stream.println(tab() + "!!! " + x);
		return log(x);
	}

	/**
	 * Prints the methodName with a border, and then adds the methodName to the
	 * stack.
	 * 
	 * @param methodName
	 * @return
	 */
	public Logger beginMethod(final String methodName) {
		String message = border(TAB_LENGTH) + START + methodName;
		borderMessage(message);
		stack.add(methodName);
		return this;
	}

	/**
	 * Removes the last methodName from the stack and prints it with a border.
	 * 
	 * @return
	 */
	public Logger endMethod() {
		final String methodName = stack.remove(stack.size() - 1);
		String message = border(TAB_LENGTH) + END + methodName;
		return borderMessage(message);
	}
	
	private Logger borderMessage(String message) {
		stream.println(tab()
				+ message
				+ border(BORDER_LENGTH - (TAB_LENGTH * stack.size())
						- message.length()));
		return this;
	}

	/**
	 * Returns a String to be used as a border.
	 * 
	 * @param x
	 * @return
	 */
	private String border(final int x) {
		StringBuilder border = new StringBuilder();
		for (int y = 0; y < x; y++) {
			border.append(BORDER[stack.size()]);
		}
		return border.toString();
	}

	/**
	 * Returns a String consisting of the appropriate number of tabs based on
	 * the size of the stack List.
	 * 
	 * @return
	 */
	private String tab() {
		String tabs = "";
		for (int i = 0; i < stack.size(); i++) {
			tabs += '\t';
		}
		return tabs;
	}

	/**
	 * @return the stream
	 */
	public PrintStream getStream() {
		return stream;
	}

	/**
	 * @param stream
	 *            the stream to set
	 * @param stream
	 * @return this
	 */
	public Logger setStream(PrintStream stream) {
		this.stream = stream;
		return this;
	}

}

{'fraction_non_alphanumeric': 0.12141050438922779, 'fraction_numerical': 0.0041660467192382086, 'mean_word_length': 2.5850666666666666, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '2137979', 'n_tokens_mistral': 2318, 'n_tokens_neox': 1993, 'n_words': 698}