https://github.com/ruyadorno/simple-output
Output messages to stdout/stderr
https://github.com/ruyadorno/simple-output
javascript js nodejs stderr stdout
Last synced: 13 days ago
JSON representation
Output messages to stdout/stderr
- Host: GitHub
- URL: https://github.com/ruyadorno/simple-output
- Owner: ruyadorno
- License: mit
- Created: 2014-08-02T23:08:03.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-03-07T03:51:42.000Z (about 2 years ago)
- Last Synced: 2024-04-14T19:52:34.088Z (about 1 year ago)
- Topics: javascript, js, nodejs, stderr, stdout
- Language: JavaScript
- Size: 357 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-output
[](https://npmjs.org/package/simple-output)
[](https://travis-ci.org/ruyadorno/simple-output)
[](https://raw.githubusercontent.com/ruyadorno/simple-output/master/LICENSE)Pretty output messages to stdout/stderr with no extra dependencies.
![]()
## Getting Started
Install the module with: `npm install simple-output`## Examples
```javascript
var log = require('simple-output');log.success('Successful hello world');
```## Available methods
- success(msg)
- info(msg)
- warn(msg)
- error(msg)
- node(msg) prints a green hexagon icon (on supported platforms) along with msg
- message(msg) prints msg, no icon associated with it
- hint(msg) useful if you want to dim some of the output## 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
```javascript
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
```javascript
var requireInject = require('require-inject');var myModule = requireInject('../my-module', {
'simple-output': {
info: msg => assert(msg, 'hello world');
}
});myModule.methodThatUsesSimpleLogInfoInternally();
```## License
[MIT](LICENSE) © 2022 [Ruy Adorno](http://ruyadorno.com)