Package Exports
- log-output
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (log-output) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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 = require('log-output');
var frames = 'lorem ipsum dolor sit'.split(' ');
var frame = 0;
setInterval(function() {
frame = frames[frame++ % frames.length];
logOutput(frames[frame]);
}, 1000);
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 = require('log-output');
var customAdapter = function() {
// Assuming you have a custom stream with a non-standard interface
var stream = require('custom-stream');
return {
resetLine: function() {},
newLine: function() {},
resetCursor: function(position) {},
output: function() {}
}
};
logOutput.adapter(customAdapter);
logOutput('yay'); // 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.
Thoughts on log-update
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