<commit_before>/*jslint node: true*/
/* global exports */
"use strict";

var moment = require('moment'),
    colors = require('colors');

exports.logTimestamp = function () {
    var timestamp = moment().format('D MMM YYYY, H:mm:ss');
    return timestamp.blue;
};

exports.compose = function (action, targetUrl, req, reqMoment) {
    switch (action) {
    case 'processing':
        return ['Processing url'.yellow, targetUrl, 'for', req.headers['user-agent'].grey, '(' + req.headers.host + ')'];
    case 'request-error':
        return ['Error occured with url'.red, targetUrl, '(' + req.headers.host + ')'];
    case 'success':
        return ['Served static version of'.green, targetUrl, '(' + req.headers.host + ')', 'in', moment().diff(reqMoment, 'milliseconds') + 'ms'];
    case 'wrong-args':
        return ['Wrong request arguments'.red, 'from', req.headers['user-agent'].grey, '(' + req.headers.host + ')'];
    }
};

exports.perform = function () {
    var record = [];
    record.push(this.logTimestamp());
    record = record.concat(this.compose.apply(this, arguments));
    console.log.apply(console, record);
    return record.join('');
};<commit_msg>Logger module exports only one method<commit_after>/*jslint node: true*/
/* global exports */
"use strict";

var moment = require('moment'),
    colors = require('colors');

function logTimestamp() {
    var timestamp = moment().format('D MMM YYYY, H:mm:ss');
    return timestamp.blue;
}

function compose(action, targetUrl, req, reqMoment) {
    switch (action) {
    case 'processing':
        return ['Processing url'.yellow, targetUrl, 'for', req.headers['user-agent'].grey, '(' + req.headers.host + ')'];
    case 'request-error':
        return ['Error occured with url'.red, targetUrl, '(' + req.headers.host + ')'];
    case 'success':
        return ['Served static version of'.green, targetUrl, '(' + req.headers.host + ')', 'in', moment().diff(reqMoment, 'milliseconds') + 'ms'];
    case 'wrong-args':
        return ['Wrong request arguments'.red, 'from', req.headers['user-agent'].grey, '(' + req.headers.host + ')'];
    }
}

exports.perform = function () {
    var record = [];
    record.push(logTimestamp());
    record = record.concat(compose.apply(this, arguments));
    console.log.apply(console, record);
    return record.join('');
};
{'fraction_non_alphanumeric': 0.18916595012897677, 'fraction_numerical': 0.0, 'mean_word_length': 3.691532258064516, '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': '7607718', 'n_tokens_mistral': 712, 'n_tokens_neox': 708, 'n_words': 168}