# log-prepend

> Prepend a string to each line of console output

Latest version **0.0.1010** (published 2018-07-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install log-prepend
pnpm add log-prepend
yarn add log-prepend
bun add log-prepend
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.1010 |
| Published | 2018-07-18 |
| First published | 2017-09-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Olegzandr VD |
| Maintainers | oresoftware |
| Keywords | prepend, transform, stdout, stderr |

## Links

- npm: https://www.npmjs.com/package/log-prepend
- Repository: https://github.com/ORESoftware/log-prepend
- Homepage: https://github.com/ORESoftware/log-prepend#readme
- Issues: https://github.com/ORESoftware/log-prepend/issues
- npm.io page: https://npm.io/package/log-prepend

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.1010 (latest) — 2018-07-18
- 0.0.1009 — 2018-05-30
- 0.0.1008 — 2017-12-06
- 0.0.1007 — 2017-10-28
- 0.0.1006 — 2017-10-08
- 0.0.1005 — 2017-09-10
- 0.0.1003 — 2017-09-10
- 0.0.1001 — 2017-09-01

## README

# log-prepend

Create a console.log or console.error like function, but prepend a string to each line.

## API

```js
const {lp} = require('log-prepend');
const log = lp(' [suman] ', process.stdout);
const logerr = lp(' [suman error] ', process.stderr);

log('a','b','c');
log('log1', 'log2\n3',4,5 + '\n55');

```

To use colors in the prepending string, simply do:

```js
const chalk = require('chalk');
const log = lp(chalk.blue(' [suman] '), process.stdout);
const logerr = lp(chalk.red(' [suman error] '), process.stderr);
```


# Extra

This works as a rudimentary solution:

```js
const log = console.log.bind(console, ' [suman] ');
```

But the problem with the above log function is that it won't handle new lines chars that are passed to it.

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