<commit_before>
module.exports.info = function (from, msg) {
  setTimeout(function () {
    log('info', from, msg);
  }, 1);
};

module.exports.err = function (from, msg) {
  setTimeout(function () {
    log('err', from, msg);
  }, 1);
};

function log(type, from, msg) {
  var now = new Date(Date.now());
  now = now.getFullYear() + '/' + now.getMonth() + '/' + now.getDate() +
    ' ' + now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();

  if (typeof from === 'undefined') {
    from = ''
  } else {
    from = '[' + from[0].toUpperCase() + from.slice(1) + ']';
  }

  if (typeof msg === 'object') {
    msg = JSON.stringify(msg);
  }

  if (type == 'info') {
    console.log(now + ' ' + from + ' ' + msg);
  } else if (type == 'err') {
    console.error(now + ' ' + from + ' ' + msg);
  }
}<commit_msg>Fix a bug in logger.<commit_after>
module.exports.info = function (from, msg) {
  setTimeout(function () {
    log('info', from, msg);
  }, 1);
};

module.exports.err = function (from, msg) {
  setTimeout(function () {
    log('err', from, msg);
  }, 1);
};

function log(type, from, msg) {
  var now = new Date(Date.now());
  now = now.getFullYear() + '/' + now.getMonth() + '/' + now.getDate() +
    ' ' + now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();

  if (typeof from === 'undefined') {
    from = ''
  } else {
    from = '[' + from[0].toUpperCase() + from.slice(1) + ']';
  }

  if (typeof msg === 'object') {
    try {
      msg = JSON.stringify(msg);
    } catch (TypeError) {
      console.log(msg);
      return;
    }
  }

  if (type == 'info') {
    console.log(now + ' ' + from + ' ' + msg);
  } else if (type == 'err') {
    console.error(now + ' ' + from + ' ' + msg);
  }
}
{'fraction_non_alphanumeric': 0.2322357019064125, 'fraction_numerical': 0.00462160600808781, 'mean_word_length': 2.669491525423729, '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': '4344424', 'n_tokens_mistral': 653, 'n_tokens_neox': 645, 'n_words': 133}