coa-node-logging

3.1.1 • Public • Published

coa-node-logging

Common interface to logging for COA node scripts

Logging Standards

City of Asheville node applications should follow the logging guidelines from 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

Readme

Keywords

none

Package Sidebar

Install

npm i coa-node-logging

Weekly Downloads

24

Version

3.1.1

License

MIT

Unpacked Size

8.22 kB

Total Files

7

Last publish

Collaborators

  • coa-dev-user
  • ejaxon
  • mmazanec22
  • fruiz7