Created
November 29, 2013 16:20
-
-
Save wilf312/7708116 to your computer and use it in GitHub Desktop.
PHPのエラーログをNode.jsで監視して通知してもらう。(Mac専用?) ref: http://qiita.com/wilf312/items/083aca26e8c7deccc684
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# パスはここに書く 相対パスは試してないけどいけるかな? | |
targetFile = "/PHP/logs/php_error.log" | |
# ファイルの読み込み | |
fs = require("fs") | |
exec = require('child_process').exec | |
# ファイルを監視 | |
fs.watch( targetFile, (event, filename)-> | |
console.log "event is: " + event | |
# ファイルの変更キャッチ | |
if event is "change" | |
# コマンドの実行 | |
exec("terminal-notifier -message 'PHP ERROR!' -title 'm9(^Д^)'", (err, stdout, stderr) -> | |
console.log err | |
) | |
# 本当は末端行だけ取得してexecのメッセージに渡したらもっと幸せになれるかも | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment