# printit

> Dirty logging with class

Latest version **0.1.20** (published 2016-04-25) · 0 weekly downloads

## Install

```sh
npm install printit
pnpm add printit
yarn add printit
bun add printit
```

## 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.1.20 |
| Published | 2016-04-25 |
| First published | 2013-12-17 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Cozy Cloud |
| Maintainers | mycozycloud |
| Keywords | requests, http, json, client |

## Links

- npm: https://www.npmjs.com/package/printit
- Repository: https://github.com/frankrousseau/printit
- Homepage: https://github.com/frankrousseau/printit/
- Issues: https://github.com/frankrousseau/printit/issues
- npm.io page: https://npm.io/package/printit

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.1.20 (latest) — 2016-04-25
- 0.1.19 — 2016-03-24
- 0.1.18 — 2016-02-22
- 0.1.17 — 2016-02-22
- 0.1.16 — 2016-02-22
- 0.1.15 — 2015-11-30
- 0.1.14 — 2015-11-09
- 0.1.13 — 2015-11-09
- 0.1.12 — 2015-11-08
- 0.1.11 — 2015-11-08
- 0.1.10 — 2015-10-29
- 0.1.9 — 2015-09-25
- 0.1.8 — 2015-06-18
- 0.1.7 — 2015-06-09
- 0.1.6 — 2015-02-22
- … 4 more at https://npm.io/package/printit/versions

## README

## It began with a console.log...

You are probably like me, you always put some dirty logs in your software. You
want to keep them dirty but you want fancy colors in your terminal, not in
production, and you don't want to see this log displayed in your test output.
At last, you don't care much about log level, the classical
info/debug/warn/error is enough for you. Say welcome to printit the dirty
logger with class!

### Display rules

The way printit displays things is changed via environment variable:

* Debug messages are not displayed.
* When NODE_ENV is 'production', it doesn't display colors (it's better when you cat/tail a log file).
* When NODE_ENV is 'test', it doesn't display logs (logs make mocha output 
  looks less messy).
* When DEBUG is 'true', it displays the debug messages.

### Examples

```javascript
var printit = require('printit');

var log = printit({
  prefix: 'my app',
  date: true
});

log.info("Print this with a blue info label and my app prefix and date");
log.debug("Print this with a green debug label and my app prefix and date");
log.warn("Print this with a yellow warn label and my app prefix and date");
log.error("Print this with a red error label and my app prefix and date");

log = printit({
  prefix: 'my app',
  date: false
});
log.error("Print this with a red error label and my app prefix");

log.error("Test 7");
log.error("Print this with a red error label");
```

### Send logs to a file

It is possible to use a custom `console`, for example if you want to send logs
to a file:

```javascript
var fs = require('fs')
var Console = require('console').Console;
var printit = require('printit');

var out = fs.createWriteStream('log.txt');
printit.console = new Console(out, out);

var log = printit({
  prefix: 'my app',
  date: true
});

log.info("Print this with a blue info label and my app prefix and date");
```

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