Skip to content

Instantly share code, notes, and snippets.

@wilf312
Created November 29, 2013 16:20
Show Gist options
  • Save wilf312/7708116 to your computer and use it in GitHub Desktop.
Save wilf312/7708116 to your computer and use it in GitHub Desktop.
PHPのエラーログをNode.jsで監視して通知してもらう。(Mac専用?) ref: http://qiita.com/wilf312/items/083aca26e8c7deccc684
# パスはここに書く 相対パスは試してないけどいけるかな?
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