# 4log

> Line, HTTP Response and Error logger

Latest version **0.1.1** (published 2016-12-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install 4log
pnpm add 4log
yarn add 4log
bun add 4log
```

## 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.1 |
| Published | 2016-12-23 |
| First published | 2016-09-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Maxim Ponomarev |
| Maintainers | maxvipon |
| Keywords | log, logger |

## Links

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

## Dependencies (2)

- [pff](https://npm.io/package/pff.md) ^1.0.0
- [datef](https://npm.io/package/datef.md) ^3.0.0

## 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.1.1 (latest) — 2016-12-23
- 0.1.0 — 2016-09-12

## README

# 4log [![Build Status](https://travis-ci.org/maxvipon/4log.svg?branch=master)](https://travis-ci.org/maxvipon/4log)

> Line, HTTP Response and Error logger


## Install

```
$ npm install --save 4log
```


## Usage

```js
const log = require('4log')('ctrl:index');

log.msg('unicorns');
// Format: [datetime] [pid] type who "message"
// => [12/Sep/2016:11:56:51 +0500] [74640] MSG ctrl:index "unicorns"

log.err(new Error('foobar'));
// Format: [datetime] [pid] type who "message" "stack"
// => [12/Sep/2016:09:53:28 +0300] [74640] ERR ctrl:index "ERROR:  index returned tuples in wrong order" "Error: ERROR:  index returned tuples in wrong order >>  >>     at Client._readError (/node_modules/pg-native/index.js:80:13) >>     at Client._read (/node_modules/pg-native/index.js:121:19) >>     at PQ.emit (events.js:104:17)"

log.res(res);
// format: [datetime] [pid] type who IP "method url" status "message" "request_id"
// => [12/Sep/2016:11:34:00 +0300] [74640] RES ctrl:index 2a02:6b8:0:1625::6 "GET /v1/locations/foobar" 404 "Unsupported location" "7b5f10be25e111b2483f2b7e856feeac"
```


## API

### log(name[, outStream[, errStream]])

#### name

Type: `String`

Name of the Logger instance.

#### outStream

Type: `Stream`<br>
Default: `stdout`

Writable stream for MSG and RES logs.

#### errStream

Type: `Stream`<br>
Default: `stderr`

Writable stream for ERR logs.

### log.msg(str[, arg1[, arg2,[ … argN]]])

#### str

Type: `String`

Sting for log. It may contain formatters `%s` or `%d` similar to `console.log`

### log.err(err)

#### err

Type: `Error`

### log.res(res[, err])

#### res

Type: `Response`

Express Response.

#### err

Type: `Error`

Error for logging response error.

## License

MIT © [Maxim Ponomarev](https://github.com/maxvipon)

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