"Bunyan" is \fBa simple and fast a JSON logging library\fR for node\.js services, a one\-JSON\-object\-per\-line log format, and \fBa \fBbunyan\fR CLI tool\fR for nicely viewing those logs\. This man page describes the latter\.
.
.SS"Pretty\-printing"
A bunyan log file is a stream of JSON objects, optionally interspersed with non\-JSON log lines\. The primary usage of bunyan(1) is to pretty print, for example:
.
.IP""4
.
.nf
$ bunyan foo\.log # or `cat foo\.log | bunyan
[2012\-02\-08T22:56:52\.856Z] INFO: myservice/123 on example\.com: My message
extra: multi
line
[2012\-02\-08T22:56:54\.856Z] ERROR: myservice/123 on example\.com: My message
\.\.\.
.
.fi
.
.IP""0
.
.P
By default the "long" output format is used\. Use the \fB\-o FORMAT\fR option to emit other formats\. E\.g\.:
.
.IP""4
.
.nf
$ bunyan foo\.log \-o short
22:56:52\.856Z INFO myservice: My message
extra: multi
line
22:56:54\.856Z ERROR myservice: My message
\.\.\.
.
.fi
.
.IP""0
.
.P
These will color the output if supported in your terminal\. See "OUTPUT FORMATS" below\.
.
.SS"Filtering"
The \fBbunyan\fR CLI can also be used to filter a bunyan log\. Use \fB\-l LEVEL\fR to filter by level:
.
.IP""4
.
.nf
$ bunyan foo\.log \-l error # show only \'error\' level records
[2012\-02\-08T22:56:54\.856Z] ERROR: myservice/123 on example\.com: My message
.
.fi
.
.IP""0
.
.P
Use \fB\-c COND\fR to filter on a JavaScript expression returning true on the record data\. In the COND code, \fBthis\fR refers to the record object:
.
.IP""4
.
.nf
$ bunyan foo\.log \-c `this\.three` # show records with the \'extra\' field
[2012\-02\-08T22:56:52\.856Z] INFO: myservice/123 on example\.com: My message
Process bunyan:log\-* probes from the process with the given PID\. Can be used multiple times, or specify all processes with \'*\', or a set of processes whose command & args match a pattern with \'\-p NAME\'\.
Specify an output format\. One of \fBlong\fR (the default), \fBshort\fR, \fBjson\fR, \fBjson\-N\fR, \fBbunyan\fR (the native bunyan 0\-indent JSON output) or \fBinspect\fR\.
In Bunyan log records, then \fBlevel\fR field is a number\. For the \fB\-l|\-\-level\fR argument the level \fBnames\fR are supported as shortcuts\. In \fB\-c|\-\-condition\fR scripts, uppercase symbols like "DEBUG" are defined for convenience\.
On systems that support DTrace (e\.g\., MacOS, FreeBSD, illumos derivatives like SmartOS and OmniOS), Bunyan will create a DTrace provider (\fBbunyan\fR) that makes available the following probes:
.
.IP""4
.
.nf
log\-trace
log\-debug
log\-info
log\-warn
log\-error
log\-fatal
.
.fi
.
.IP""0
.
.P
Each of these probes has a single argument: the string that would be written to the log\. Note that when a probe is enabled, it will fire whenever the corresponding function is called, even if the level of the log message is less than that of any stream\.
\fBbunyan\fR is written in JavaScript and requires node\.js (\fBnode\fR)\. The project lives at \fIhttps://github\.com/trentm/node\-bunyan\fR and is published to npm as "bunyan"\.