<commit_before>//debugger;
var log = []; //Create global variable for logs.

//Global function for sending the log file to me via email.
function sendLog() {
  //debugger;
  //For now, I'll just dump the log into the console until I have email setup.
  console.log('Begin log dump...');
  for( var i = 0; i < log.length; i++ ) {
    console.log(log[i]);
  }
  console.log('...End log dump.');
  
  var obj = new Object();
  obj.log = log;
  $.get('/api/email/sendlog', obj, function(data) {
    console.log('Log file emailed to administrator.');
  });
}<commit_msg>Developing email API and sendlog to use it.<commit_after>//debugger;
var log = []; //Create global variable for logs.

//Global function for sending the log file to me via email.
function sendLog() {
  //debugger;
  //For now, I'll just dump the log into the console until I have email setup.
  console.log('Begin log dump...');
  for( var i = 0; i < log.length; i++ ) {
    console.log(log[i]);
  }
  console.log('...End log dump.');
  
  var obj = new Object();
  obj.log = log;
  $.get('/api/email/sendlog', obj, function(data) {
    console.log('Log file emailed to administrator.');
  })
  .fail(function( jqxhr, textStatus, error ) {
    debugger;

    var err = textStatus + ", " + error;

    try {
      if(jqxhr.responseJSON.detail == "invalid csrf") {
        global.modalView.errorModal('Update failed due to a bad CSRF token. Please log out and back in to refresh your CSRF token.');
        return;
      } else {
        global.modalView.errorModal("Request failed because of: "+error+'. Error Message: '+jqxhr.responseText);
        console.log( "Request Failed: " + error );
        console.error('Error message: '+jqxhr.responseText);
      }
    } catch(err) {
      console.error('Error trying to retrieve JSON data from server response.');
    }            
  });
}
{'fraction_non_alphanumeric': 0.14802809292274446, 'fraction_numerical': 0.0010804970286331713, 'mean_word_length': 2.8106995884773665, 'pattern_counts': {'":': 0, '<': 5, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2843402', 'n_tokens_mistral': 585, 'n_tokens_neox': 573, 'n_words': 196}