Edit on
var gulp = require('gulp');
var gulp = require('gulp');
var notify = require("gulp-notify");
var intercept = require('gulp-intercept');
var lastErrorTime = null;                                // Last Error Log time
var myRegx = /\[(.*?)\] \[(.*?)\] \[(.*?)\] \[(.*?)\]/i; // Regex to retrive error
var logPath = "/var/log/apache2/error.log";              // Path To Error log file

gulp.task('default', ['watch']);

gulp.task('watch', function() {

	gulp.watch([logPath]).on('change', function(file) {
		gulp.src([file.path])
		    .pipe(intercept(function(fileScaned){
		    	var errorLines = fileScaned.contents.toString().split('\n'),
		    		errorTempLines = [],
		    		displayLines = [],
		    		lastDisplayLines = 1;

		    	for (var i = 0; i < errorLines.length; i++) {
		    		if(errorLines[i].indexOf("PHP Fatal error:") > -1){
		    			errorTempLines.push(errorLines[i]);
		    		} else if(errorLines[i].indexOf("PHP Parse error:") > -1) {
		    			errorTempLines.push(errorLines[i]);
		    		}
		    	};

		    	if(errorTempLines.length <= lastDisplayLines){
		    		displayLines = errorTempLines;
		    	} else {
			    	for (var i = 0; i < lastDisplayLines; i++) {
			    		var error = errorTempLines[errorTempLines.length - lastDisplayLines - i];

			    		if(error.indexOf("PHP Fatal error:") > -1){
			    			errorArray = error.split("PHP Fatal error:");
			    		} else if(error.indexOf("PHP Parse error:") > -1) {
			    			errorArray = error.split("PHP Parse error:");
			    		}

			    		var errorTime = myRegx.exec(errorArray[0])[1],
			    			errorMsg = errorArray[1];

			    		if(lastErrorTime != errorTime){
				    		displayLines.push(errorMsg);
				    		
				    		lastErrorTime = errorTime;
			    		}
			    	};
		    	}

		    	if(displayLines.length){
		    		gulp.src(file.path).pipe(notify("Time: "+lastErrorTime+"\n "+ displayLines.join("\n\n")));
		    	}
		    }));
    })
});
Rerun