# print-messages

> We console lots, this handles everything

Latest version **0.3.2** (published 2013-12-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install print-messages
pnpm add print-messages
yarn add print-messages
bun add print-messages
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2013-12-07 |
| First published | 2013-11-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | Daniel Hastings Schumann |
| Maintainers | danschumann |
| Keywords | console, log, print, formatted |

## Links

- npm: https://www.npmjs.com/package/print-messages
- Repository: https://github.com/danschumann/print-messages
- Issues: https://github.com/danschumann/print-messages/issues
- npm.io page: https://npm.io/package/print-messages

## Dependencies (3)

- [when](https://npm.io/package/when.md) ~2.6.0
- [colors](https://npm.io/package/colors.md) ~0.6.2
- [underscore](https://npm.io/package/underscore.md) ~1.5.2

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.3.2 (latest) — 2013-12-07
- 0.3.1 — 2013-12-01
- 0.3.0 — 2013-12-01
- 0.2.2 — 2013-11-23
- 0.2.1 — 2013-11-23
- 0.2.0 — 2013-11-23
- 0.1.1 — 2013-11-23
- 0.1.0 — 2013-11-23
- 0.0.8 — 2013-11-23
- 0.0.7 — 2013-11-23
- 0.0.6 — 2013-11-23
- 0.0.5 — 2013-11-23
- 0.0.4 — 2013-11-23
- 0.0.3 — 2013-11-23
- 0.0.2 — 2013-11-23
- … 2 more at https://npm.io/package/print-messages/versions

## README

print-messages
==============

Because making `console.log` easier to read and write is a double edge sword of time saving.

    npm install print-messages
    
```js
pm = require('print-messages');
```

Besides normal stuff like colored `log`, `warn`, `success`, and `error` methods, we have 2 more

* `node`
* `promise`

------------------------

Node.js usually has callbacks like `function(err, result){ ...`
```js
user.save(function(er,res){
    // String will be green or red depending on er, res
    pm.node('user.save results...', er, res);
})
```

-----------------------------

Promises are becoming popular
```js
var promiser = require('when');
willSucceed = promiser.defer()

pm.promise('promise result is(green or red): ', willSucceed.promise);
willSucceed.resolve("resolve is green");

// or we could have done this
//willSucceed.reject("reject is red");
```

--------------------------

#Examples

####Basic log, warn, success, error
![example-image](https://rawgithub.com/danschumann/print-messages/master/example_images/basic_example.gif)
```js
pm.log('log me', 'log me long tim');
pm.warn('warn me', 'warn me long tim');
pm.success('success me', 'success me long tim');
pm.error('error me', 'error me long tim');
```

#### Node callbacks  
![example-image](https://rawgithub.com/danschumann/print-messages/master/example_images/node_example.gif)
```js
// Node callbacks are usually (err, res)
pm.node('some failing save message', 'That failed', null);
pm.node('some success message', null, {
  results: 'are cool'
});
```

#### Promises    
![example-image](https://rawgithub.com/danschumann/print-messages/master/example_images/promise_example.gif)
```js
promise = require('when');
    
willSucceed = promise.defer();
willFail = promise.defer();
    
pm.promise('This is for a promise', willSucceed.promise);
willSucceed.resolve('That works');

pm.promise('Whereas this is for a promise', willFail.promise);
willFail.reject('That fails');
```

------------------------------
Patch Notes
------------------------------

v0.3.0

Updated from coffee-script to js.

Added `newLine [=true]` and `blankLine [=true]` options to determine if arguments should be on new lines and if each log should be preceeded by a blank line.  Both false looks like this:

    pm.newLine = false;
    pm.blankLine = false;

![example-image](https://rawgithub.com/danschumann/print-messages/master/example_images/newLine_example.png)


Added a way to change colors.

    pm.colors.error = 'magenta';
    pm.colors.success = 'blue';
    pm.init()

![example-image](https://rawgithub.com/danschumann/print-messages/master/example_images/colors_example.png)

v0.2.2

Ensured at least 1 printed message will appear, even if first arg is an object

v0.2.0

Added `pm.node_cb` for `user.save(pm.node_cb('My message might be green or red'))`

v0.1.0

Added `pm.crash` and `pm.crash_cb`
for `promise.otherwise(pm.crash)` or `promise.otherwise(pm.crash_cb('with message'))`

Added `pm.error_cb`, `pm.success_cb`, `pm.warn_cb`, `pm.log_cb`
for `user.save().error(pm.error_cb('it failed)); // logs: 'it failed'.red, errors...`

---
_Source: https://npm.io/package/print-messages · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
