<commit_before>var bunyan = require('bunyan');

var logger = bunyan.createLogger({
  name: 'app',
  streams: [{
    level:'info',
    path:'app.log'
  }]
});

var logStr = function(type,requestId,api,func){
  logger.info({type:type, requestId:requestId,api:api,func:func});
}

var simulate = function(){
  logStr('entering','myuser','web server','web call');
  logStr('entering','myuser','user','getUser');
  logStr('entering','myuser','service','calculate');
  logStr('entering','myuser','db','getData');

  setTimeout(logStr,Math.random() * 1000,'exiting','myuser','web server','web call');
  setTimeout(logStr,Math.random() * 1000,'exiting','myuser','user','getUser');
  setTimeout(logStr,Math.random() * 1000,'exiting','myuser','service','calculate');
  setTimeout(logStr,Math.random() * 1000,'exiting','myuser','db','getData');
}

module.exports = {
  logger : logger,
  simulate: simulate
}<commit_msg>log only if level enabled<commit_after>var bunyan = require('bunyan');

var logger = bunyan.createLogger({
  name: 'app',
  streams: [{
    level:'info',
    path:'app.log'
  }]
});

var logStr = function(type,requestId,api,func){
  if(bunyan.INFO === logger.levels(0)){
    logger.info({type:type, requestId:requestId,api:api,func:func});
  }
}

var simulate = function(){
  logStr('entering','myuser','web server','web call');
  logStr('entering','myuser','user','getUser');
  logStr('entering','myuser','service','calculate');
  logStr('entering','myuser','db','getData');

  setTimeout(logStr,Math.random() * 1000,'exiting','myuser','web server','web call');
  setTimeout(logStr,Math.random() * 1000,'exiting','myuser','user','getUser');
  setTimeout(logStr,Math.random() * 1000,'exiting','myuser','service','calculate');
  setTimeout(logStr,Math.random() * 1000,'exiting','myuser','db','getData');
}

module.exports = {
  logger : logger,
  simulate: simulate
}
{'fraction_non_alphanumeric': 0.2214514407684098, 'fraction_numerical': 0.017609391675560297, 'mean_word_length': 7.259911894273127, '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': '4977317', 'n_tokens_mistral': 663, 'n_tokens_neox': 630, 'n_words': 86}