0.0.3 â€ĸ Published 1 year ago

@graphshieldhq/logging v0.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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:

VALUESEVERITYKEYWORDDESCRIPTIONEXAMPLES
0EmergencyemergSystem is unusableThis level should not be used by applications.
1AlertalertShould be corrected immediatelyLoss of the primary ISP connection.
2CriticalcritCritical conditionsA failure in the system's primary application.
3ErrorerrError conditionsAn application has exceeded its file storage limit and attempts to write are failing.
4WarningwarningMay indicate that an error will occur if action is not taken.A non-root file system has only 2GB remaining.
5NoticenoticeEvents that are unusual, but not error conditions.
6InformationalinfoNormal operational messages that require no action.An application has started, paused or ended successfully.
7DebugdebugInformation useful to developers for debugging the application.

Additional resources