# rtp-logger

> Registered traveller programme logger

Latest version **4.0.0** (published 2017-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install rtp-logger
pnpm add rtp-logger
yarn add rtp-logger
bun add rtp-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 | 4.0.0 |
| Published | 2017-11-09 |
| First published | 2016-03-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^6.11.4 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | UK Home Office Registered Traveller Team |
| Maintainers | noelsharpe, ukhomeoffice |

## Links

- npm: https://www.npmjs.com/package/rtp-logger
- Repository: https://github.com/UKHomeOffice/rtp-logger
- Homepage: https://github.com/UKHomeOffice/rtp-logger#readme
- Issues: https://github.com/UKHomeOffice/rtp-logger/issues
- npm.io page: https://npm.io/package/rtp-logger

## Dependencies (1)

- [winston](https://npm.io/package/winston.md) ^2.1.1

## Recent versions

- 4.0.0 (latest) — 2017-11-09
- 3.0.0 — 2017-10-10
- 1.4.0 — 2016-08-03
- 2.0.1 — 2016-03-23
- 1.1.1 — 2016-03-07
- 1.1.0 — 2016-03-07

## README

# rtp-logger  [![Build Status](https://img.shields.io/travis/UKHomeOffice/rtp-logger.svg)](https://travis-ci.org/UKHomeOffice/rtp-logger)

Thin wrapper around [winston](https://www.npmjs.com/package/winston) for use in Registered Traveller Programme node.js applications.

## Usage

To use the logger simply add **rtp-logger** to your dependencies in the `package.json` and then require it in your main javascript file.

The default are as follows: -
- Console transport logging to stdout and stderr
- Log level = debug
- Include timestamps on log entries

``` 
  logger.info('message');
```

To log objects, simply pass an additional parameter to the logging function. This will be Stringified using the `util.inspect` module


``` 
  logger.error('message', {'key': 'value});
```

### Configuration

To configure the logger further you can use the `setup()` function, passing an object. Below is an example of the options that can be used: -

``` JavaScript
{
    loglevel: 'info',
    appName: 'MY-APP', // will appear as [MY-APP] in log entries
    transports: {
        console: {
            // any valid winston config options when creating a console transport
            timestamp: false,
            debugStdout: false
        }
    }
}
```

## Run tests

The unit tests are written in mocha and can be run using npm. 
```
npm test
```

You can also run the tests using grunt. Before running the unit tests it will perform a run jshint and jscs. From the project root, run the following: -

```
grunt dev
```

If you would like to watch all javascript files and automatically re-run jshint, jscs and mocha you can use the following: -

```
grunt watch
```

## File transport

File logging is not currently a requirement as all logs file are created from stdout and stderr and will be for the foreseeable future. However, the code to handle configuration of a file transport was written and is available in the `file-transport` branch. Should this be required at a later date, it could be merged into the master branch and used.

To configure the logger with a file transport you can use the `setup()` function, passing an object. Below is an example of the options that can be used: -

``` JavaScript
{
    logLocation: '/log/test.log'
    transports: {
        file: {
            // any valid winston config options when creating a file transport
            filename: 'some-log-file.log', // this would override logLocation
            timestamp: false,
            maxsize: 128,
            maxFiles: 1
        }
    }
}
```

The existence of `logLocation` or `transports.file` in the config will trigger the addition of a file transport to the logger.

If only `logLocation` is present then the default config for a file transport will be used, this is as defined here.

``` JavaScript
{
    filename: // logLocation or 'app.log'
    timestamp: true,
    maxsize: 10240,
    maxFiles: 3
}
```

The Registered Traveller Programme uses BrowserStack for mobile and desktop testing https://www.browserstack.com/

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