Skip to content

A simple and efficient Node.js package for logging errors and messages to files and the console.

License

Notifications You must be signed in to change notification settings

makstyle119/node-error-logger.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node-Error-Logger.JS

A simple and efficient Node.js package for logging errors and messages to files and the console.

Features:

  • Supports error, warning, and info logs.
  • Logs messages with timestamps and severity levels.
  • Saves logs to separate files based on date and level.
  • Provides clear and concise API for logging.

Installation:

npm i node-error-logger.js

Usage

  1. Import the Logger module:
const Logger = require('node-error-logger.js');
  1. Use the provided logging functions:
Logger.info('Application started successfully.');

// Log an error with an optional error object
const myError = new Error('Something went wrong!');
Logger.error('An error occurred!', myError);

API:

  • Logger.info(message): Logs an informational message.
  • Logger.warn(message): Logs a warning message.
  • Logger.error(message, error): Logs an error message. (Optional error object for stack trace)

Example:

const Logger = require('node-error-logger.js');

// Log messages throughout your application
Logger.info('Processing data...');

try {
  // Your application logic here
} catch (error) {
  Logger.error('An error occurred!', error);
}

Logger.warn('A potential issue might arise.');

Benefits:

  • Improves debugging by providing detailed logs.
  • Helps monitor application behavior and identify errors.
  • Easy to integrate into your Node.js projects.

About

A simple and efficient Node.js package for logging errors and messages to files and the console.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published