<commit_before>var _ = require('lodash');
var pad = require('pad');
var chalk = require('chalk');

var getNextColorFn = (function(){
	var colors = [
		'green',
		'yellow',
		'blue',
		'magenta',
		'cyan',
		'gray'
	];
	var i = -1;
	return function(){
		i++;
		if(i >= colors.length){
			i = 0;
		}
		return chalk[colors[i]];
	};
}());

var logs = {};
var max_len = 0;
var show_ids = false;

module.exports = function(my_name){
	if(!logs.hasOwnProperty(my_name)){
		logs[my_name] = 0;
	}else{
		show_ids = true;//show ids if at least one task has more than one instance
	}
	var my_id = logs[my_name];
	logs[my_name]++;

	var color = getNextColorFn();

	var prefix = function(){
		var n = my_name + (show_ids ? '.' + my_id : '');
		if(n.length > max_len){
			max_len = n.length;
		}
		return color((new Date()).toString().substr(16, 8), pad(n, max_len), '|');
	};

	return {
		log: function(){
			console.log.apply(console, [prefix()].concat(_.toArray(arguments)));
		},
		err: function(){
			console.error.apply(console, [prefix()].concat(_.toArray(arguments).map(function(a){
				return chalk.red(JSON.stringify(a));
			})));
		}
	};
};<commit_msg>ensuring the logs '|' char is lined up right from the start<commit_after>var _ = require('lodash');
var pad = require('pad');
var chalk = require('chalk');

var getNextColorFn = (function(){
	var colors = [
		'green',
		'yellow',
		'blue',
		'magenta',
		'cyan',
		'gray'
	];
	var i = -1;
	return function(){
		i++;
		if(i >= colors.length){
			i = 0;
		}
		return chalk[colors[i]];
	};
}());

var logs = {};
var max_len = 0;
var show_ids = false;

module.exports = function(my_name){
	if(!logs.hasOwnProperty(my_name)){
		logs[my_name] = 0;
	}else{
		show_ids = true;//show ids if at least one task has more than one instance
	}
	var my_id = logs[my_name];
	logs[my_name]++;

	var color = getNextColorFn();

	var prefix = function(){
		var n = my_name + (show_ids ? '.' + my_id : '');
		if(n.length > max_len){
			max_len = n.length;
		}
		return color((new Date()).toString().substr(16, 8), pad(n, max_len), '|');
	};
	prefix();//little hack so that max_len get's updated asap

	return {
		log: function(){
			console.log.apply(console, [prefix()].concat(_.toArray(arguments)));
		},
		err: function(){
			console.error.apply(console, [prefix()].concat(_.toArray(arguments).map(function(a){
				return chalk.red(JSON.stringify(a));
			})));
		}
	};
};
{'fraction_non_alphanumeric': 0.19783423573511036, 'fraction_numerical': 0.0058309037900874635, 'mean_word_length': 3.813627254509018, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2695636', 'n_tokens_mistral': 996, 'n_tokens_neox': 901, 'n_words': 206}