# 4front-logger

> Bunyan based logger for 4front

Latest version **1.0.1** (published 2015-04-23) · 0 weekly downloads

## Install

```sh
npm install 4front-logger
pnpm add 4front-logger
yarn add 4front-logger
bun add 4front-logger
```

## 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 | 1.0.1 |
| Published | 2015-04-23 |
| First published | 2015-04-08 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| Author | David Von Lehman |
| Maintainers | dvonlehman |
| Keywords | 4front, log, bunyan |

## Links

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

## Dependencies (4)

- [bunyan](https://npm.io/package/bunyan.md) ^1.3.4
- [lodash](https://npm.io/package/lodash.md) ^3.6.0
- [simple-errors](https://npm.io/package/simple-errors.md) ^1.0.1
- [bunyan-request](https://npm.io/package/bunyan-request.md) ^1.1.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

- 1.0.1 (latest) — 2015-04-23
- 1.0.0 — 2015-04-08

## README

# 4front-logger

[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Build Status][travis-image]][travis-url]
[![Test Coverage][coveralls-image]][coveralls-url]

![http://4front.io](https://s3-us-west-2.amazonaws.com/4front-media/4front-logo.png)

Default logger for the 4front multi-tenant web app platform. Learn more at: [4front.io](http://4front.io)

Internally [bunyan](https://www.npmjs.com/package/bunyan) is used for JSON logging. In accordance with [12 factor app practices](http://12factor.net/logs), by default errors and warnings are are streamed to `process.stderr` and info level messages are streamed to `process.stdout`. This behavior can be overridden via the options as described below. Recommended practice is to setup a log sink external to the node app which sends log events from all servers in a cluster to a centralized logging system such as [Splunk](www.splunk.com), [Loggly](https://www.loggly.com), or [Papertrail](https://papertrailapp.com).

## Installation
~~~
npm install 4front-logger
~~~

## Usage
~~~js
var app = express();
var log = require('4front-logger')({
  loggerName: "4front-logger"
});

// Register the logger with 4front
app.settings.logger = log;
~~~

### Options
__`loggerName`__
The name of the logger which will be added by 

__`errStream`__
The stream where error level messages are written. Defaults to `process.stderr`.

__`warnStream`__
The stream where warn level messages are written. Defaults to `process.stderr`.

__`infoStream`__
The stream where info level messages are written. Defaults to `process.stdout`.

__`ignoreErrorStatus`__
Array of http `err.status` codes to ignore. Defaults to `[404]`.

### API 
Any of the methods `error`, `warn`, or `info` can be called in all the ways that [bunyan supports](https://github.com/trentm/node-bunyan#log-method-api):

~~~js
log.info("informational message");
log.info({foo: 'bar'}, 'hi');
~~~

Additionally the `error` function includes a special overload that accepts an Error object and an Express `req` object. The logger will ensure that all the error detail along with additional contextual information found on the `req` are captured in the log entry. 4front uses this method in error handling middleware:

~~~js
app.use(function(err, req, res, next) {
	log.error(err, req);
	next();
});
~~~


## Running Tests
~~~
npm test
~~~

## License
Licensed under the Apache License, Version 2.0. See the top-level file LICENSE.txt and (http://www.apache.org/licenses/LICENSE-2.0).

[npm-image]: https://img.shields.io/npm/v/4front-logger.svg?style=flat
[npm-url]: https://npmjs.org/package/4front-logger
[travis-image]: https://img.shields.io/travis/4front/logger.svg?style=flat
[travis-url]: https://travis-ci.org/4front/logger
[coveralls-image]: https://img.shields.io/coveralls/4front/logger.svg?style=flat
[coveralls-url]: https://coveralls.io/r/4front/logger?branch=master
[downloads-image]: https://img.shields.io/npm/dm/4front-logger.svg?style=flat
[downloads-url]: https://npmjs.org/package/4front-logger

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