# graceful-logger

> A simple, slim, graceful logger for Nodejs

Latest version **0.4.3** (published 2015-03-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install graceful-logger
pnpm add graceful-logger
yarn add graceful-logger
bun add graceful-logger
```

## 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.4.3 |
| Published | 2015-03-17 |
| First published | 2013-09-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | sailxjx |
| Maintainers | sailxjx |
| Keywords | logger, graceful |

## Links

- npm: https://www.npmjs.com/package/graceful-logger
- Repository: https://github.com/sailxjx/graceful-logger
- Issues: https://github.com/sailxjx/graceful-logger/issues
- npm.io page: https://npm.io/package/graceful-logger

## Dependencies (1)

- [colors](https://npm.io/package/colors.md) ^1.0.3

## 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.4.3 (latest) — 2015-03-17
- 0.4.2 — 2015-02-03
- 0.4.1 — 2014-06-26
- 0.4.0 — 2014-05-28
- 0.3.2 — 2014-04-28
- 0.3.1 — 2014-04-15
- 0.3.0 — 2014-03-12
- 0.2.5 — 2014-02-19
- 0.2.4 — 2014-02-19
- 0.2.3 — 2014-01-28
- 0.2.2 — 2014-01-15
- 0.2.1 — 2014-01-15
- 0.2.0 — 2014-01-13
- 0.1.6 — 2013-12-27
- 0.1.5 — 2013-11-12
- … 7 more at https://npm.io/package/graceful-logger/versions

## README

Graceful-Logger
======
A simple, slim, graceful logger for Nodejs

[![build status](https://api.travis-ci.org/sailxjx/graceful-logger.png)](https://travis-ci.org/sailxjx/graceful-logger)

# Capture

![capture](https://raw.github.com/sailxjx/graceful-logger/master/capture/capture.png)

# Example
```coffeescript
logger = require('../lib')

logger.info('Hello', 'World!')
logger.warn({a: 'a', b: 'b'})
logger.err(-> "This is a function")

logger.format('medium')

logger.info('Hello', 'World!')
logger.warn({a: 'a', b: 'b'})
logger.err(-> "This is a function")

# Other features
## Output multi lines
logger.info '''
This is a multi line message:
Hello everyone.
Have a nice day!
'''

## Output required package
logger.info require('path')

## Output empty message
logger.info()

## Define any colors
logger.format ':level.blue :msg.grey'
logger.info('hello world')

## Use the numeric placeholder
logger.format ':level :0.grey :1.blue'
logger.info('hello', 'world')
```

# Benchmark
```
Console x 5,367 ops/sec ±2.96% (89 runs sampled)  # console.log
Log x 5,556 ops/sec ±1.76% (93 runs sampled)      # The tiny log module written by tj
Logger x 5,612 ops/sec ±0.95% (96 runs sampled)   # This module
Fastest is Logger,Log,Console
```

# ChangeLog
## 0.4.0
1. Remove multi-line prefix (v0.3.1) for the sake of efficiency
2. User can define any color of the message by `.(color)` format, but it only works after the `:(label)` expression, e.g. `:level.green :msg.grey`
3. The `:msg` flag now support numbers for express the message of the correct index, e.g. `:1.green :2.grey`, and you will get an  green 'hello' and a grey 'world' by using `logger.info('hello', 'world')`. Remember, the index start from 0.

## 0.3.2
1. User can redefine `color` and `level` prefix by set the `color` and `level` property of each method.

## 0.3.1
1. Add prefix to each line when messages have multi lines.

## 0.3.0
1. Write message to process.stdout or process.stderr stream
2. Use `util.format` to format object/function/array etc, as the same of `console.log`
3. Add `setStream` and `getStream` to `get/set` writable stream of each method
4. Add `error` as alias of `err`, `warning` as alias of `warn`

## 0.2.1
1. Move exit feature from logger.err to logger.exit

## 0.2.0
1. Use meanful tags such as :date, :level, etc...
2. Remove custom prefix
3. Use JSON.stringify to output objects

# License

MIT

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