<commit_before>import appRoot from 'app-root-path';
import { createLogger, transports, format } from 'winston';
const { combine, timestamp, colorize } = format;


// instantiate a new Winston Logger with the settings defined above
const logger = createLogger({
	transports: [
		new (transports.Console)({
			level: process.env.NODE_ENV === 'production' ? 'error' : 'debug',
			handleExceptions: true,
			format: combine(
				timestamp(),
				colorize(),
				format.simple(),
			),
		}),
	],
	exitOnError: false,
});

export class LoggerStream {
	public name: string;
	public level: string;

	constructor(name: string, level?: string) {
		this.name = name;
		this.level = level || 'info';
	}
	public write(message: string) {
		if (this.name) {
			logger.log(this.level, this.name + ' ' + message);
		} else {
			logger.info(this.level, message);
		}
	}
}

if (process.env.NODE_ENV === 'production') {
	logger.debug('Logging initialized at production level');
} else {
	logger.debug('Logging initialized at development level, set NODE_ENV === \'production\' for production use.');
}

export default logger;<commit_msg>Remove color from production logs<commit_after>import appRoot from 'app-root-path';
import { createLogger, transports, format } from 'winston';
const { combine, timestamp, colorize } = format;


// instantiate a new Winston Logger with the settings defined above
const isProductionMode = process.env.NODE_ENV === 'production';

let level = 'debug';
let logFormat = combine(
	timestamp(),
	colorize(),
	format.simple(),
);

if (isProductionMode) {
	level = 'error';
	logFormat = combine(
		timestamp(),
		format.simple(),
	);
}
const logger = createLogger({
	transports: [
		new (transports.Console)({
			level,
			handleExceptions: true,
			format: logFormat,
		}),
	],
	exitOnError: false,
});

export class LoggerStream {
	public name: string;
	public level: string;

	constructor(name: string, level?: string) {
		this.name = name;
		this.level = level || 'info';
	}
	public write(message: string) {
		if (this.name) {
			logger.log(this.level, this.name + ' ' + message);
		} else {
			logger.info(this.level, message);
		}
	}
}

if (isProductionMode) {
	console.log('Logging initialized at production level'); 
} else {
	logger.debug('Logging initialized at development level, set NODE_ENV === \'production\' for production use.');
}

export default logger;
{'fraction_non_alphanumeric': 0.1417157275021026, 'fraction_numerical': 0.0, 'mean_word_length': 4.217105263157895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6052225', 'n_tokens_mistral': 798, 'n_tokens_neox': 734, 'n_words': 210}