Deprecation notice 🚨
I strongly suggest you to move to
log-update
that came out a little after I first wrote this module. It's really complete and making the switch should be really easy. Also, PhantomJS 2.1 has finally came out solving the problems I was trying to work around with this module.
log-output
Persist log messages on the command line.
Formerly write.js.
Install
$ npm install --save log-output
Usage
var logOutput = ;var frames = 'lorem ipsum dolor sit';var frame = 0; ;
API
logOutput(message)
message
Required
Type: string
Output message.
logOutput.stream()
Type: Stream object
Specify a stream to output.
logOutput.adapter()
Specify a writable stream interface, which is essentially an adapter.
The interface must implement the following API:
resetLine()
- Reset current output linenewLine()
- Add a new output lineresetCursor([position])
- Reset cursor position (position
defaults to0
)output(message)
- Output message
Official adapters are:
log-output-node
- Node.js adapter. This is the default adapter.log-output-phantom
- PhantomJS adapter.
You can specify your own:
var logOutput = ;var { // Assuming you have a custom stream with a non-standard interface var stream = ; return {} {} {} {} }; logOutput;; // yay
logOutput.clear()
Shortcut to empty current output.
logOutput.done()
Shortcut to output a new line.
Motivation
I wanted to visually persist log messages on the command line. Turns out this can be a bit tricky, that's why I have created this module.
log-update
Thoughts on log-update
is essentially the same idea of log-output
but it was released later and has no support for stream adapters.
Adapters support was one of the reasons I've created this module in the first place. I needed a way to persist the log messages within a PhantomJS instance.
License
MIT © Rafael Rinaldi