Inspects object and adds results to a bag.
This entire bag is logged at process.on('exit')
.
Same as @see ocat.log, but writes to ocat.tmpFile * at /tmp/ocat.txt
on Unixes and who knows on Windows (os.tmpdir()/ocat.txt
).
This is useful if you want to read isolated ocat output into your editor without other output, i.e. by your test runner.
Vim Example:
:r !OCAT_COLOR=0 OCAT_DEPTH=0 OCAT_RM=1 node % 2>&1 > /dev/null && cat /tmp/ocat.txt
will read the ocat printed output right into your editor. You should probably bind that to a shortcut. ;)
Tail Example:
In another terminal pane do:
tail -f /tmp/ocat.txt
to see logged objects every time you run your tests/code.
Inspects object and logs it to stderr immediately.
The given opts override all other options for each supplied property, which are derived as follows:
prefix: '', suffix: '', indent: '', color: true, depth: 1, commaFirst: true
OCAT_COLOR
and OCAT_COMMAFIRST
to override the related defaults, i.e.
OCAT_COLOR=0 node my.js
includes no colorsocat.create
for that ocat
instance onlyocat.log
and ocat.bag
(Object)
object to inspect
Name | Description |
---|---|
opts.prefix String?
|
the prefix to insert before the logged object |
opts.suffix String?
|
the suffix to insert after the logged object |
opts.indent String?
|
the indentation to apply to each line |
opts.color Boolean?
|
if
true
logging in colors
|
opts.depth Number?
|
depth to which the object is inspected |
opts.commaFirst Boolean?
|
if
true
commaFirst style is used when logging without color** (default:
true
)
|
Applies preconfigured opts with prefix + indentation and depth that work well in lots of scenarios.
const ocat = require('ocat').applyRes5Opts()
Object
:
ocat
Start out as default options @see ocat.log. Allow overriding ocat options for all instances.
Resets ocat.opts to default opts.
Creates an ocat instance with the supplied options.
(Object)
options (same as @see ocat.log)
Object
:
ocat instance
The file into which ocat.file writes. Set it to any other path you like to use instead.
Removes the ocat.tmpFile
If the an env var OCAT_RM=1
is present, the file is removed on startup.