<commit_before>
var app = corejs.app,
    fs = require('fs'),
    http = require('http'),
    util = require('util');
    
var infoLog = fs.createWriteStream(app.fullPath('log/info.log'), {flags: 'a'}),
    errorLog = fs.createWriteStream(app.fullPath('log/error.log'), {flags: 'a'}),
    accessLog;

function Logger(config, middleware) {
  
  // Attach to app singleton
  app[middleware] = this;
  
  // Define access log data in same closure (faster access)
  var accessLogConsole,
      domain = app.domain,
      appDate = app.date;
  
  // Middleware config
  this.config = config = corejs.extend({
    accessLog: true,
    accessLogConsole: true,
    accessLogFormat: null
  }, config);
  
  // Attach to log events
  app.on('info_log', this.info);
  app.on('error_log', this.error);
  
  if (config.accessLog) this.enableAccessLog();
  
}

Logger.prototype.enableAccessLog = function() {
  // Cache access log format function
  var config = this.config;
  var accessLogFormat = this.config.accessLogFormat;
  
  if (!accessLogFormat) config.accessLogFormat = accessLogFormat = function(req, res, app) {
    var ms = Date.now() - req.startTime;
    return util.format('%s (%s) %s %s %s (%sms)', app.domain, app.date(), req.method, req.url, res.statusCode, ms);
  };
  
  // Access log filter
  var accessLogFilter = function() {
    var log = accessLogFormat(this.request, this, app);
    if (config.accessLogConsole) console.log(log);
    accessLog.write(log+'\n');
  }
  
  accessLog = fs.createWriteStream(app.fullPath('log/access.log'), {flags: 'a'});
  app.on('request', function(req, res) {
    res.on('finish', accessLogFilter);
  });
}

Logger.prototype.info = function(msg) {
  infoLog.write(msg+'\n', 'utf8');
}

Logger.prototype.error = function(msg) {
  errorLog.write(msg+'\n', 'utf8');<commit_msg>Added remoteAddress to access logs<commit_after>
var app = corejs.app,
    fs = require('fs'),
    http = require('http'),
    util = require('util');
    
var infoLog = fs.createWriteStream(app.fullPath('log/info.log'), {flags: 'a'}),
    errorLog = fs.createWriteStream(app.fullPath('log/error.log'), {flags: 'a'}),
    accessLog;

function Logger(config, middleware) {
  
  // Attach to app singleton
  app[middleware] = this;
  
  // Define access log data in same closure (faster access)
  var accessLogConsole,
      domain = app.domain,
      appDate = app.date;
  
  // Middleware config
  this.config = config = corejs.extend({
    accessLog: true,
    accessLogConsole: true,
    accessLogFormat: null
  }, config);
  
  // Attach to log events
  app.on('info_log', this.info);
  app.on('error_log', this.error);
  
  if (config.accessLog) this.enableAccessLog();
  
}

Logger.prototype.enableAccessLog = function() {
  // Cache access log format function
  var config = this.config;
  var accessLogFormat = this.config.accessLogFormat;
  
  if (!accessLogFormat) config.accessLogFormat = accessLogFormat = function(req, res, app) {
    var ms = Date.now() - req.startTime;
    return util.format('%s (%s) [%s] %s %s %s (%sms)', app.domain, app.date(), req.socket.remoteAddress, req.method, 
    req.url, res.statusCode, ms);
  };
  
  // Access log filter
  var accessLogFilter = function() {
    var log = accessLogFormat(this.request, this, app);
    if (config.accessLogConsole) console.log(log);
    accessLog.write(log+'\n');
  }
  
  accessLog = fs.createWriteStream(app.fullPath('log/access.log'), {flags: 'a'});
  app.on('request', function(req, res) {
    res.on('finish', accessLogFilter);
  });
}

Logger.prototype.info = function(msg) {
  infoLog.write(msg+'\n', 'utf8');
}

Logger.prototype.error = function(msg) {
  errorLog.write(msg+'\n', 'utf8');
{'fraction_non_alphanumeric': 0.15930642102411272, 'fraction_numerical': 0.001083717149823896, 'mean_word_length': 3.5920398009950247, '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': '7528635', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1238, 'n_words': 277}