Skip to content

lettdigital/lett-log

Repository files navigation

lett-log

A simple library to manage logs using winston and syslog.

Documentation

📘 https://lettdigital.github.io/lett-log/docs

Setup

Connection

There is two ways to set a connection, the first one always override de second one!

1 - Define Connection in run time

import Log from 'lett-log';

const log = new Log({
  host: "",
  protocol: "",
  port: "",
  facility: "",
  path: "",
  appName: "",
  colors: true,
  timestamp: false,
});

2 - Environment Variables

{
  "SYSLOG_HOST": "",
  "SYSLOG_PROTOCOL": "",
  "SYSLOG_PORT": "",
  "SYSLOG_FACILITY": "",
  "SYSLOG_PATH": "",
  "APP_NAME": "",
  "LOG_COLOR": ""
}

How to use

The appName or APP_NAME should be a CONSTANT_CASE string.

Log level

There are 4 log levels:

0 - error
1 - warn
2 - info
3 - debug

Let's explain each one:

  1. error: A crash application error.
  • Example: Missing required environment variable
  1. ⚠️ warn: A error with no side effects
  • Example: The image downalod failed
  1. ℹ️ info: Informations about application lifecycle
  • Example: Express successfully started
  1. 🔷 debug: Other informations meaningful
  • Example: Running query on database

Log paramenters

Checkout the full documentation