lib/Persistence.js
function getRequiredFilename (name, callback) {
  var filepath = path.join(LOG_DIR, name);

  function getStats () {

    fs.stat(filepath, function (err, stats) {
      if (err) {
        callback(err, null);
      } else if (stats && stats.size >= MAX_FILE_SIZE) {
        createFile();
      } else {
        callback(null, name);
      }
    });
  }

  function createFile () {
    fs.writeFile(filepath, '[]', function (err) {
      if (err) {
        callback(err, null);
      } else {
        callback(null, name);
      }
    });
  }

  fs.exists(filepath, function (exists) {
    if (exists) {
      getStats();
    } else {
      createFile();
    }
  });
}
function getRequiredFilename (name, callback) {
  var filepath = path.join(LOG_DIR, name);

  function getStats () {

    fs.stat(filepath, function (err, stats) {
      if (err) {
        callback(err, null);
      } else if (stats && stats.size >= MAX_FILE_SIZE) {
        createFile();
      } else {
        callback(null, name);
      }
    });
  }

  function createFile () {
    fs.writeFile(filepath, '[]', function (err) {
      if (err) {
        callback(err, null);
      } else {
        callback(null, name);
      }
    });
  }

  fs.exists(filepath, function (exists) {
    if (exists) {
      getStats();
    } else {
      createFile();
    }
  });
}
Determine the file to write the current log file to
@param  {String}   name
@param  {Function} callback