Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including simple-output with all npm packages installed. Try it out:

var simpleOutput = require("simple-output")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

simple-output v2.1.1

Output messages to stdout/stderr

simple-output

NPM version Build Status License

Pretty output messages to stdout/stderr

Getting Started

Install the module with: npm install simple-output

Examples

var log = require('simple-output');

log.success('Successful hello world');

Available methods

  • success(msg)
  • error(msg)
  • info(msg)
  • message(msg)
  • node(msg)
  • warn(msg)

Testing

This module helps on testing your output data by making it simpler to mock simple-output and its methods or use the exposed streams interface to which the data gets written to.

In order to test your output information, replace the stdout/stderr properties with an mock object containing a write function (simulating the streams api). See the example below:

Mock simpleOutput.stdout

var log = require('simple-output');
var myModule = require('../my-module');

log.stdout = {
    write: function(msg) {
        assert(msg, 'hello world');
    }
};

myModule.methodThatUsesSimpleLogInfoInternally();

Using a mocking library

var requireInject = require('require-inject');

var myModule = requireInject('../my-module', {
    'simple-output': {
        info: msg => assert(msg, 'hello world');
    }
});

myModule.methodThatUsesSimpleLogInfoInternally();

License

MIT © 2019 Ruy Adorno

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free