# coa-node-logging

> Common interface for Node logging

Latest version **3.1.1** (published 2021-04-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install coa-node-logging
pnpm add coa-node-logging
yarn add coa-node-logging
bun add coa-node-logging
```

## 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 | 3.1.1 |
| Published | 2021-04-07 |
| First published | 2017-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Eric Jackson |
| Maintainers | coa-dev-user, ejaxon, mmazanec22, fruiz7 |

## Links

- npm: https://www.npmjs.com/package/coa-node-logging
- Repository: https://github.com/cityofasheville/coa-node-logging
- Homepage: https://github.com/cityofasheville/coa-node-logging#readme
- Issues: https://github.com/cityofasheville/coa-node-logging/issues
- npm.io page: https://npm.io/package/coa-node-logging

## Dependencies (2)

- [winston](https://npm.io/package/winston.md) ^3.1.0
- [winston-daily-rotate-file](https://npm.io/package/winston-daily-rotate-file.md) ^4.4.2

## Recent versions

- 3.1.1 (latest) — 2021-04-07
- 3.1.0 — 2020-04-23
- 3.0.0 — 2018-12-27
- 2.0.4 — 2018-09-14
- 2.0.3 — 2018-01-30
- 2.0.2 — 2018-01-23
- 2.0.1 — 2018-01-22
- 2.0.0 — 2018-01-22
- 1.2.0 — 2018-01-22
- 1.1.5 — 2018-01-22
- 1.1.4 — 2018-01-22
- 1.1.3 — 2018-01-22
- 1.1.2 — 2018-01-22
- 1.1.1 — 2018-01-22
- 1.1.0 — 2017-02-18
- … 10 more at https://npm.io/package/coa-node-logging/versions

## README

# coa-node-logging
Common interface to logging for COA node scripts

## Logging Standards

City of Asheville node applications should follow the [logging guidelines](https://www.owasp.org/index.php/Logging_Cheat_Sheet#Which_events_to_log) from [The Open Web Application Security Project](https://www.owasp.org/index.php/About_The_Open_Web_Application_Security_Project) (OWASP).

## Usage

````
  const logFile = 'path-to-log-file';
  const name = 'test-logger'; 
  const Logger = require('coa-node-logging');
  const logger = new Logger(name, logFile);
  const testObject = {
    field1: 123,
    field2: "A string",
  };
  logger.error('This is a message');
  logger.info('This is a message with an object', { name1: 'value1', name2: 2 });
  logger.warn('This is a warning message');

````

If ```logFile``` is null, output will only go to stdout. By default output is always also be logged to the console. To suppress this, override the default value of the third parameter, `logToConsole`:

````
  const logger = new Logger(name, logFile, false);
````
Note that setting ```logFile``` to null when the third parameter is also false means that no logging will be done.

## Installation
Install with
````
  npm install --save coa-node-logging
````

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