I wanted an easy way to retrieve critical errors from my Apache error log. While i was finding a solution, Gulp came into the picture. First let me introduce you to Gulp.
I have used Gulp to automate following tasks in past:
- Compiling SCSS
- Compressing CSS
- Auto reloading my browser if CSS changes.
- Compiling Coffeescripts
Now it was time to use gulp for Apache notification. So I created Gulp task for the same. Here is the script.
First of all I have included 3 Gulp dependencies which is Gulp itself as i don't have gulp in my environment, Gulp notifier to display error notification and Gulp Intercept to Go through log file and retrieve the error.
I have defined Watch as default task. Default task is a task which Gulp keep running continuously. The task keep watching over the log file. Whenever the error log file changes, Task will go through the file and will retrieve recent errors and will display them.
The script will display mainly 2 types of critical errors:
- PHP Fatal Error
- PHP Parse Error
Setup:
Requirement:
- Node
Installation Steps:
- First setup Node.
- Install Gulp
- Then clone this repository. Or Download repository from Github.
- Run
npm install
Start:
- Goto the cloned repository.
- First add path to your Apache's Php Error log file in variable "logPath". (Default is
/var/log/apache2/error.log
) - Run
sudo gulp
This comment has been removed by the author.
ReplyDeleteYou have some mistakes I think. You have not included package.json file so I am not able t o run npm install. And if I follow all steps but skill this, I get this error: "Error: Cannot find module 'gulp-notify'" even tough gulp is installed.
ReplyDeleteI installed gulp-notify and gulp-intercept and it fixed it. So please either update package.json file or add these commands in your posts.
ReplyDeleteSorry, I have uploaded package.json file in the repo.
DeleteThank you for pointing out.