Skip to content

Commit

Permalink
Allow tailing all files at once
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas committed May 15, 2019
1 parent 681f77a commit e0aa557
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/tasks/logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var defaults = {
}

function tail_command(file, lines) {
return 'tail -n' + (lines||defaultLines) + ' -f ' + file + ' || echo "Log file not found" && true';
return 'tail -n' + (lines || defaultLines) + ' -f ' + file + ' || echo "Log file not found" && true';
}

function guess_path(file) {
Expand All @@ -23,11 +23,19 @@ function prompt(role_name, logs, cb) {
type: 'list',
name: 'file',
message: 'Choose the log file to tail',
choices: Object.keys(logs)
choices: Object.keys(logs).concat('all')
// choices: Object.keys(logs).map(function(key) { return logs[key] })
}, function(answers) {
var tail_cmds = {};
tail_cmds[role_name] = tail_command(guess_path(logs[answers.file]));
if (answers.file == 'all') {
var paths = Object.keys(logs).map(function(name) {
return guess_path(logs[name]);
})
tail_cmds[role_name] = tail_command(paths.join(' '));
} else {
tail_cmds[role_name] = tail_command(guess_path(logs[answers.file]));
}

cb({ tail: tail_cmds });
})
}
Expand Down

0 comments on commit e0aa557

Please sign in to comment.