<commit_before>/* Copyright (c) 2011 <NAME> */

var util   = require('util')
var http   = require('http')
var events = require('events')


var MARK = 'logentries: '


function LogEntriesTransport( opts, logger ) {
  var self = this

  var queue = null
  var connected = false
  var req = null

  function process() {

    while( 0 < queue.length ) {
      var entry = queue[0]

      var logline = opts.token + '"' + entry.join('" "') + '"\n';
      
      try {
        queue.shift()
        logger.emit('log',logline)
        req.write(logline)
      }
      catch(e) {
        logger.emit('error',e)
        queue.unshift(entry)
        connected = false
        break
      }
    }
  }


  function connect() {
    if( req ) {
      try {
        req.end()
      }
      catch( e ) {
        logger.emit('error',e)
      }
    }

    var options = {
      host: 'api.logentries.com',
      port: 10000,
      token: opts.token
    }

    logger.emit('connect',options)

    req = http.request(options, function(res) {
      if( 200 != res.statusCode ) {
        res.setEncoding('utf8');

        var err = {
          statusCode: res.statusCode,
          headers: res.headers
        }

        var body = []
        res.on('data',function(chunk){
          body.push(chunk)
        })

        res.on('end',function(){
          try {
            err.body = JSON.parse(body.join(''))
          }
          catch(e) {
            err.body = {msg:body.join('')}
          }
          logger.emit('error',err)<commit_msg>Modified logentries to use more minimal logging format<commit_after>/* Copyright (c) 2011 <NAME> */

var util   = require('util')
var http   = require('http')
var events = require('events')


var MARK = 'logentries: '


function LogEntriesTransport( opts, logger ) {
  var self = this

  var queue = null
  var connected = false
  var req = null

  function process() {

    while( 0 < queue.length ) {
      var entry = queue[0]

      var logline = opts.token;
      // logline += '"' + entry.join('" "') + '"\n';
      logline += entry[2] + '\n';
      
      try {
        queue.shift()
        logger.emit('log',logline)
        req.write(logline)
      }
      catch(e) {
        logger.emit('error',e)
        queue.unshift(entry)
        connected = false
        break
      }
    }
  }


  function connect() {
    if( req ) {
      try {
        req.end()
      }
      catch( e ) {
        logger.emit('error',e)
      }
    }

    var options = {
      host: 'api.logentries.com',
      port: 10000,
      token: opts.token
    }

    logger.emit('connect',options)

    req = http.request(options, function(res) {

      if( 200 != res.statusCode ) {
        res.setEncoding('utf8');

        var err = {
          statusCode: res.statusCode,
          headers: res.headers
        }

        var body = []
        res.on('data',function(chunk){
          body.push(chunk)
        })

        res.on('end',function(){
          try {
            err.body = JSON.parse(body.join(''))
          }
          catch(e) {
            err.body = {msg:body.join('')}
          }
          logger.emit('error',err)
{'fraction_non_alphanumeric': 0.14603881641743557, 'fraction_numerical': 0.009863188036907413, 'mean_word_length': 1.6486941870261163, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1361558', 'n_tokens_mistral': 1029, 'n_tokens_neox': 970, 'n_words': 208}