diff --git a/bin/bunyan b/bin/bunyan index 995a9da8..57b11aa1 100755 --- a/bin/bunyan +++ b/bin/bunyan @@ -1069,7 +1069,16 @@ function emitRecord(rec, line, opts, stylize) { rec._cS = stylize.start; // Shortcut for "colorEnd" rec._cE = stylize.end; - emit(opts.template ? opts.template(rec) : 'No template defined. Use --template.' +'\n'); + + var out; + try { + out = opts.template ? opts.template(rec) : 'No template defined. Use --template.'; + } + catch(e) { + // Unprocessable line, display default + out = JSON.stringify(rec, null, opts.jsonIndent); + } + emit(out + '\n'); break; default: throw new Error('unknown output mode: '+opts.outputMode);