node.js mac 10.9 console.log

问题描述:

使用节点js移动文件等使用mac。 使用plist使我的文件在后台移动。 使用console.log来跟踪发生了什么。 必须从运行10.6的mac移动到运行10.9的mac。 console.log不显示在10.9控制台中。node.js mac 10.9 console.log

比如这个脚本:

console.log('This works and you are good at stuff.'); 

这个plist中一起:

<?xml version="1.0" encoding="UTF-8"?> 
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 
    <plist version="1.0"> 
    <dict> 
     <key>Label</key> 
     <string>com.gillstudios.consoleLogTest</string> 
     <key>ProgramArguments</key> 
     <array> 
      <string>/usr/local/bin/node</string> 
      <string>/Library/Scripts/Custom/ConsoleLogTest_001.js</string> 
     </array>  
     <key>StartInterval</key> 
     <integer>30</integer> 
    </dict> 
    </plist> 

在10.6,我得到一个消息,每隔30秒。在10.9中我什么也没有得到,即使当我使用文件移动脚本时,MOVE文件,但我没有得到控制台中的任何东西。

感谢您的任何见解。

我最终制作了自己的日志并在控制台中打开它。 (日期变量在脚本的前面部分创建)

function customLog(logMessage){ 
    var logfile = '/Library/Logs/AutomationLog/' + year + thisMonth + date + '_automation.txt' 
    var logtime = hour + ':' + minutes + ':' + seconds; 
    fs.stat(logfile, function(err,stats){ 
     // if (err) customLog(err); // Throws ENOENT if file doesn't exist. 
     if (!err && stats.isFile()){ 
      fs.appendFileSync(logfile, logtime + ' ' + logMessage + '\n'); 
     } else { 
      fs.writeFile(logfile, logtime + ' ' + logMessage + '\n'); 
     }; 
    }); 
} 

然后我做了一个查找和替换的console.log /的CustomLog。在控制台中,我去了File/Open(我的文件)。如果还有更好的方法我仍然想知道,但这是一个有效的解决方案。