title: How to create a file with unique id using nodejs?
body: <p>I want to create file into specified directory with unique id's, Any idea what is implemented wrong in below code. 
  Two things here ..</p>
  
  <p>1- Its not generating files into specific directory <code>records</code> , how can i create file into specific directory ?</p>
  
  <p>2- Using node uuid , How can i create unique id's for each file that is being generated ?</p>
  
  <p>logs.js</p>
  
  <pre><code>var uuid = require('node-uuid');
  var fs = require('fs');
  var path = './app/records'
  var filename = 'server' + uuid.v4() + '.txt'
  var userLogs = function (data) {
      fs.writeFile(path,filename,data,function () {
          console.log(filename);
      });
      console.log('userLogs', data);
  };
  module.exports = userLogs;
  </code></pre>
  
  <p>output filenames have same id's</p>
  
  <pre><code>userLogs [ 'Test Log  messages' ]
  server7695c20a-5ddf-4d67-a437-3d0b9d354ed1.txt
  userLogs [ 'Test Log  messages' ]
  server7695c20a-5ddf-4d67-a437-3d0b9d354ed1.txt
  info: Test Log  messages
  from console Test Log  messages
  userLogs [ 'Test Log  messages', 'Test Log  messages' ]
  server7695c20a-5ddf-4d67-a437-3d0b9d354ed1.txt 
  </code></pre>