# log-fn

> Logging library build on top of 'chalk' and 'boxen'

Latest version **2.1.0** (published 2017-10-06) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.0 |
| Published | 2017-10-06 |
| First published | 2017-03-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | self_refactor |
| Maintainers | self_refactor |
| Keywords | log, logging, console |

## Links

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

## Dependencies (10)

- [ms](https://npm.io/package/ms.md) ^2.0.0
- [ora](https://npm.io/package/ora.md) ^1.3.0
- [q-i](https://npm.io/package/q-i.md) ^1.2.0
- [boxen](https://npm.io/package/boxen.md) ^1.2.1
- [chalk](https://npm.io/package/chalk.md) ^2.1.0
- [rambda](https://npm.io/package/rambda.md) ^0.9.1
- [figures](https://npm.io/package/figures.md) ^2.0.0
- [rambdax](https://npm.io/package/rambdax.md) ^0.6.1
- [log-symbols](https://npm.io/package/log-symbols.md) ^2.0.0
- [gradient-string](https://npm.io/package/gradient-string.md) ^0.1.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

- 2.1.0 (latest) — 2017-10-06
- 2.0.11 — 2017-10-05
- 2.0.10 — 2017-10-01
- 2.0.9 — 2017-09-26
- 2.0.8 — 2017-09-04
- 2.0.7 — 2017-08-24
- 2.0.6 — 2017-08-24
- 2.0.5 — 2017-08-24
- 2.0.4 — 2017-06-28
- 2.0.3 — 2017-06-27
- 2.0.2 — 2017-06-11
- 2.0.1 — 2017-05-29
- 2.0.0 — 2017-05-17
- 1.5.1 — 2017-05-17
- 1.6.0 — 2017-05-04
- … 16 more at https://npm.io/package/log-fn/versions

## README

# Log-fn
Logging library build with 'chalk'

### Example use

```
// yarn add log-fn
const log = require('log-fn')
log('foo')

const x = {bar: {baz: 'foo'}}
log({x}, 'pattern')
```

### Typing

```
log(...inputCollection: Array<any>, rules: String)
```

### Rules

- Your last argument act as rule for logging.
- You can pass more than one rule using separator `.`
- For example `log(1,'icon.back')` or `log(1,'spin.tag=foo')`
- You can disable `log-fn` all along by setting `process.env.LOG_FN_FLAG` to `false`

#### Default behaviour

> log(x)

```
log(1,2,3, ["foo"], null) // Line 1
log(1, {a: 1}, undefined) // Line 2
log('foo', 'bar') // Line 3
```

Line 1 will log all of the inputs using the first color of predefinet set of colors.
Line 2 will log all of the inputs using the second color of predefinet set of colors.

When object is passed as part of `inputCollection`, it will go to the end of the log.

The reason is that `chalk` works with strings, and objects don't have `toString` method.
So objects are logged with plain `console.log`, while all other types use `chalk`.

Line 3 will log only `'foo'` as last argument `'bar'` is a `String` and is used as `rules` option.

#### With background

> (log(x, 'back'))

// if array with object

```
log(1,2,3, ["foo"], null, 'back') // Line 4
log(1, {a: 1}, undefined, 'back') // Line 5
```

The same as default behaviour, but we are setting not only the color of the text,
but also its background.

#### Pattern logging

> log({ x }, 'pattern')

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