index.js
function logChat(from, message) {
  if (typeof config.log !== 'string' || !from || typeof message !== 'string')
    return;

  // Get the current moment
  var now = moment();

  // Create the file name
  var file = path.join(config.log, now.format('YYYY-MM-DD') + '-' + 'chat.log');

  // Create the text to log based on moment and chat info
  var text = '[' + now.format('YYYY-MM-DD hh:mm A') + '] ' + from + ': ' + message + '\n';

  // Append the text to the log file
  fs.appendFile(file, text, function(err) {
    if (err)
      error(err);
  });
}
function logChat(from, message) {
  if (typeof config.log !== 'string' || !from || typeof message !== 'string')
    return;

  // Get the current moment
  var now = moment();

  // Create the file name
  var file = path.join(config.log, now.format('YYYY-MM-DD') + '-' + 'chat.log');

  // Create the text to log based on moment and chat info
  var text = '[' + now.format('YYYY-MM-DD hh:mm A') + '] ' + from + ': ' + message + '\n';

  // Append the text to the log file
  fs.appendFile(file, text, function(err) {
    if (err)
      error(err);
  });
}
function logChat ( from , message ) { if ( typeof config . log !== 'string' || ! from || typeof message !== 'string' ) return ; // Get the current moment var now = moment ( ) ; // Create the file name var file = path . join ( config . log , now . format ( 'YYYY-MM-DD' ) + '-' + 'chat.log' ) ; // Create the text to log based on moment and chat info var text = '[' + now . format ( 'YYYY-MM-DD hh:mm A' ) + '] ' + from + ': ' + message + '\n' ; // Append the text to the log file fs . appendFile ( file , text , function ( err ) { if ( err ) error ( err ) ; } ) ; }
Log message to chat logs

@param from    {string} - name of person sending the message
@param message {string} - the message sent
Log message to chat logs