Socket
Socket
Sign inDemoInstall

node_smart_logger

Package Overview
Dependencies
308
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node_smart_logger


Version published
Weekly downloads
39
increased by1850%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Node Smart Logger

A library that allows you to keep better control of your daily logs in Node


Install

npm i node_smart_logger

Start it

import { SmartLogger } from 'node_smart_logger';

const _logger = new SmartLogger();

By default logger will create a logs folder in the root of your project, but you can also indicate the path and name of the logs folder when you initialize it:

const config = {
    logs_folder_path: "./someDir/anotherDir",
    logs_folder_name: "anotherLogsFolderName"
}
const _logger = new SmartLogger(config);

Opciones de Configuración:

  • logs_folder_path : String - [Ruta donde se generará el archivo de logs] [defaul: "./"]
  • logs_folder_name : String - [Nombre del directorio donde se guardaran los logs] [default: "logs"]
  • show_terminal : Boolean - [Habilita o inhabilita mostrar logs en el terminal] [default: "true"]
  • write_file : Boolean - [Habilita o inhabilita escribir los logs en el archivo] [default: "true"]

Disable logs for terminal during test, set environment variable

SET TEST_LOGS=false

logs

These logs are saved to a file in your directory

// normal log
_logger.setLog("message");
_logger.terminalLog("message");// only terminal output
//2022-5-28 9:21:6 | message | {}

// Info log
_logger.setInfo("message");
_logger.terminalInfo("message");// only terminal output
//2022-5-28 9:21:6 | INFO | message | {}

// Error log
_logger.setError("message");
_logger.terminalError("message");// only terminal output
//2022-5-28 9:21:6 | ERROR | message | {}

// Alert log
_logger.setAlert("message");
_logger.terminalAlert("message");// only terminal output
//2022-5-28 9:21:6 | ALERT | message | {}

// Debug log
_logger.setDebug("message");
_logger.terminalDebug("message");// only terminal output
//2022-5-28 9:21:6 | DEBUG | message | {}

// Critical log
_logger.setCritical("message");
_logger.terminalCritical("message");// only terminal output
//2022-5-28 9:21:6 | CRITICAL | message | {}

// Warning log
_logger.setWarning("message");
_logger.terminalWarning("message");// only terminal output
//2022-5-28 9:21:6 | WARNING | message | {}

// Success log
_logger.setSuccess("message");
_logger.terminalSuccess("message");// only terminal output
//2022-5-28 9:21:6 | SUCCESS | message | {}

// Trace log [return a trace of route]
_logger.setTrace("message");
_logger.terminalTrace("message");// only terminal output
//2022-5-28 9:21:6 | TRACE | message | {}
/*
    myOtherFUnction
    myFunction
    onclick
*/


Logs agree to receive a data object


const dataToLog = {
    error: false,
    message: 'some message'
}

_logger.setCritical("log message", dataToLog);
//2022-5-28 9:21:6 | critical  | log message | {"error":false,"message":"some message"}


Logs only for terminal

Steep

_logger.setSteep({message: 'some message',number: 5});
//[ steep 5 ] :::: some message

Cantity

_logger.setCantity({message: 'Total Records', total: 100});
//Total Records [100]

Interval

_logger.setInterval({message: 'Record Processed', actual: 5, total: 100});
//Record Processed [5] of [100]

You can create titles with background according to the level of the log

Title

_logger.setTitle({message: "This is a error tittle", level: "error"});


Title levels available

  • info
  • warning
  • error
  • alert
  • critical
  • success
  • degub

FAQs

Last updated on 14 Jun 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc