Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quiet output format #249

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions bin/bunyan
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@ var OM_INSPECT = 3;
var OM_SIMPLE = 4;
var OM_SHORT = 5;
var OM_BUNYAN = 6;
var OM_QUIET = 7;
var OM_FROM_NAME = {
'long': OM_LONG,
'paul': OM_LONG, /* backward compat */
'json': OM_JSON,
'inspect': OM_INSPECT,
'simple': OM_SIMPLE,
'short': OM_SHORT,
'bunyan': OM_BUNYAN
'bunyan': OM_BUNYAN,
'quiet': OM_QUIET
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accidental removal of 'bunyan' there?

};


Expand Down Expand Up @@ -232,6 +234,7 @@ function printHelp() {
p(' bunyan: 0 indented JSON, bunyan\'s native format');
p(' inspect: node.js `util.inspect` output');
p(' short: like "long", but more concise');
p(' quiet: like "short", but only outputs details if level >= WARN');
p(' -j shortcut for `-o json`');
p(' -0 shortcut for `-o bunyan`');
p(' -L, --time local');
Expand Down Expand Up @@ -730,8 +733,13 @@ function handleLogLine(file, line, opts, stylize) {
*/
function emitRecord(rec, line, opts, stylize) {
var short = false;
var quiet = false;

switch (opts.outputMode) {
case OM_QUIET:
quiet = true;
/* jsl:fall-thru */

case OM_SHORT:
short = true;
/* jsl:fall-thru */
Expand Down Expand Up @@ -786,6 +794,7 @@ function emitRecord(rec, line, opts, stylize) {
delete rec.pid;

var level = (upperPaddedNameFromLevel[rec.level] || 'LVL' + rec.level);
var rawLevel = rec.level;
if (opts.color) {
var colorFromLevel = {
10: 'white', // TRACE
Expand Down Expand Up @@ -1028,14 +1037,22 @@ function emitRecord(rec, line, opts, stylize) {
onelineMsg,
extras,
details));
else
else if (!quiet || (rawLevel > INFO)) {
emit(format('%s %s %s:%s%s\n%s',
time,
level,
nameStr,
onelineMsg,
extras,
details));
}
else
emit(format('%s %s %s:%s%s\n',
time,
level,
nameStr,
onelineMsg,
extras));
break;

case OM_INSPECT:
Expand Down