@shopup/logger
TypeScript icon, indicating that this package has built-in type declarations

4.0.2 • Public • Published

Usage

import logger from '@blendo/node-logger'

logger.error("message",{any:"extra data"})
logger.info("message",{any:"extra data"})
logger.warning("message",{any:"extra data"})

Levels

{
  emerg: 0,
  alert: 1,
  crit: 2,
  error: 3,
  warning: 4,
  notice: 5,
  info: 6,
  debug: 7
}

Format

{
    "level":"info",
    "timestamp":"2019-03-18T09:48:40.539Z",
    "message":"message",
    "metadata": {"any":"extra data"}
}

Configuration

In each application optionally, should add a configuration property like the following.

logger:
    sentry:
        dsn:  # {String} (default: null) Sentry client key (Project -> settings -> Client Keys)
        level:  # {String} (default: error) Log level,
    console: # {Boolean} (default: true) show logs in console: false in production by default
    slack:
        token:  # {String} (default: null) Slack app token (...),
        level:  # {String} (default: crit) Log level,
        username:  # {String} (default: service name) The username of the sender,
        channel:  # {String} (default: null) Channel id,
    rotation: # If rotation is not set, will be disabled
        filename: # {String} (default: application.log) Specifies the generated filename.
        rotatedFilename: # {String} (default: {filename}-%DATE%.%INDEX%.log) Specifies the filename of the file generated by the rotation. Filename can include optionally placeholders, to take control of the name of the rotated file. available placeholders are: %DATE%:the date using the datePattern option, %INDEX%: tha index of the file.
        path: # {String} (default: null) Specifies the base path for files.
        size: # {String} (default: 20M) Specifies the file size to rotate the file. (B: Bites K: KiloBites M: MegaBytes G: GigaBytes)
        interval: # {String} (default: null) Specifies the time interval to rotate the file.(ie: '5s', '5m','2h','1d','1M')
        datePattern: # {String} (default: YYYY-MM-DD) A string representing the moment.js date format to be used for rotating.
        compress: # {Boolean} (default: true) Specifies compression method of rotated files.
        maxFiles: # {Integer} (default: null) Specifies the maximum number of rotated files to keep.
        maxSize: # {String} (default: null) Specifies the maximum size of rotated files to keep.

for more about rotation, check rotating-file-stream

Readme

Keywords

none

Package Sidebar

Install

npm i @shopup/logger

Weekly Downloads

57

Version

4.0.2

License

none

Unpacked Size

210 kB

Total Files

16

Last publish

Collaborators

  • ssbeefeater