 Config  = require './common/config'
 
 WriteLog  = (fd, data) =>
-    toLog = '[' + ((do Moment).format 'YYYY MMM DD hh:mm:ssa') + '] ' + data
-    Fs.writeSync fd, toLog, 0, toLog.length
+    if data?
+        toLog = '[' + ((do Moment).format 'YYYY MMM DD hh:mm:ssa') + '] ' + data
+        Fs.writeSync fd, (new Buffer toLog), 0, toLog.length
 
 processes = []
 

if Config.Websocket.Enabled
    wsAccessLog = Fs.openSync (Path.join Config.Paths.Logs, 'ws.access.log'), 'a+'
    wsErrorLog  = Fs.openSync (Path.join Config.Paths.Logs, 'ws.error.log'), 'a+'
    ws          = spawn 'node', [(Path.join Config.Paths.Approot, 'lib', 'ws', 'websocket.js')]
    ws.stdout.on 'data', (data) =>
        process.stdout.write "#{data}"
        WriteLog wsAccessLog, data

if Config.Voicious.Enabled
    voiciousAccessLog = Fs.openSync (Path.join Config.Paths.Logs, 'voicious.access.log'), 'a+'
    voiciousErrorLog  = Fs.openSync (Path.join Config.Paths.Logs, 'voicious.error.log'), 'a+'
    voicious          = spawn 'node', [(Path.join Config.Paths.Root, 'lib', 'core', 'voicious.js')]
    voicious.stdout.on 'data', (data) =>
        process.stdout.write "#{data}"
        WriteLog voiciousAccessLog, data
