@graphshieldhq/logging

0.0.3 • Public • Published

Versioning Twitter Follow

Configuration Module

An opinionated logging module.

💡 Features

🚀 Get Started

Installation

npm install --save @graphshieldhq/logging

Initialization

import logging from '@graphshieldhq/logging'
logging.init({
    log_level: 'debug',
    console_transport_enabled: true,
    file_transport_enabled: false,
    file_transport_max_file_size: '5m',
    file_transport_max_files: '14d',
    file_transport_directory: './logs',
    syslog_transport_enabled: false,
    syslog_transport_host: 'localhost',
    syslog_transport_port: 514,
    syslog_transport_protocol: 'udp4',
    syslog_transport_path: '/dev/log',
    syslog_transport_facility: 'local0',
    syslog_transport_type: 'BSD',
    syslog_app_name: 'test',
    metadata: {
        deploy: 'test'
    }
})

The initialization options must be an object with properties as specified in the options schema.

Usage

logger.log({ level: 'info', message: 'Hello world', data: { foo: 'bar' } })

The logging module supports the standard syslog levels:

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

Corresponding to the following severity levels:

VALUE SEVERITY KEYWORD DESCRIPTION EXAMPLES
0 Emergency emerg System is unusable This level should not be used by applications.
1 Alert alert Should be corrected immediately Loss of the primary ISP connection.
2 Critical crit Critical conditions A failure in the system's primary application.
3 Error err Error conditions An application has exceeded its file storage limit and attempts to write are failing.
4 Warning warning May indicate that an error will occur if action is not taken. A non-root file system has only 2GB remaining.
5 Notice notice Events that are unusual, but not error conditions.
6 Informational info Normal operational messages that require no action. An application has started, paused or ended successfully.
7 Debug debug Information useful to developers for debugging the application.

Additional resources

Package Sidebar

Install

npm i @graphshieldhq/logging

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

32 kB

Total Files

11

Last publish

Collaborators

  • guillaumemeyer