From 492d1229d6bc2e41f87920fde8f1648164f425d7 Mon Sep 17 00:00:00 2001 From: Bryan Cantrill Date: Wed, 15 May 2013 22:40:51 -0700 Subject: [PATCH] issue #88: should be able to efficiently combine "-l" with "-p *" --- bin/bunyan | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/bin/bunyan b/bin/bunyan index 16020d9..384de34 100755 --- a/bin/bunyan +++ b/bin/bunyan @@ -177,7 +177,7 @@ function printHelp() { p(' -h, --help print this help info and exit'); p(' --version print version of this command and exit'); p(''); - p('Dtrace options (only on dtrace-supporting platforms):'); + p('DTrace options (only on dtrace-supporting platforms):'); p(' -p PID Process bunyan:log-* probes from the process'); p(' with the given PID. Can be used multiple times,'); p(' or specify all processes with "*", or a set of'); @@ -1102,7 +1102,22 @@ function processPids(opts, stylize, callback) { } var probes = pids.map(function (pid) { - return format('bunyan%s:::log-*', pid); + if (!opts.level) + return format('bunyan%s:::log-*', pid); + + var rval = [], l; + + for (l in levelFromName) { + if (levelFromName[l] >= opts.level) + rval.push(format('bunyan%s:::log-%s', pid, l)); + } + + if (rval.length != 0) + return rval.join(','); + + warn('bunyan: error: level (%d) exceeds maximum logging level', + opts.level); + return drainStdoutAndExit(1); }).join(','); var argv = ['dtrace', '-Z', '-x', 'strsize=4k', '-qn', format('%s{printf("%s", copyinstr(arg0))}', probes)];