Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Dynamically search and replace server logs when they change. Uses gulp.js and node
"name": "process-log",
"version": "1.0.0",
"description": "Dynamically search and replace server logs when they change",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"keywords": [
"author": "Jan Beck",
"license": "MIT",
"dependencies": {
"gulp": "^3.9.1",
"gulp-replace": "^0.6.1",
"minimist": "^1.2.0"
// USAGE: gulp process-log -s <SEARCH> -r <REPLACE> -f <FILE>
var gulp = require('gulp'),
replace = require('gulp-replace'),
path = require('path'),
minimist = require('minimist'),
options = minimist(process.argv.slice(2)),
FgMagenta = "\x1b[35m",
FgCyan = "\x1b[36m",
FgNormal = "\x1b[0m";
gulp.task('process-log', function(){
// watch given file for changes, function(event){
console.log('Processing file', FgMagenta, String(event.path), FgNormal );
// perform search replace with given options
.pipe(replace(String(options.s), String(options.r)))
// overwrite original
console.log('Replaced all instances of', FgCyan, String(options.s), FgNormal, 'with', FgCyan, String(options.r), FgNormal );
return true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.