1.0.9 • Published 5 months ago

masklogger-node v1.0.9

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

Custom Logger

A versatile logger module for Node.js with customizable logging levels and transports.

Installation

To install the package, use npm or yarn:

npm install masklogger-node
# or
yarn add masklogger-node

Importing

const Logger = require('masklogger-node');
// or using ES6 import
import Logger from 'masklogger-node';

Creating Logger Instances

const fileTransport = new FileTransport({ filename: path.join(__dirname, 'combined.log'), level: LogLevelText.ERROR });
const consoleTransport = new ConsoleTransport();

const logger = new Logger({
  transports: [consoleTransport, fileTransport],
});

Logging Levels

Logging Messages

The logger instance supports different log levels:

error(message: string)
warn(message: string)
info(message: string)
success(message: string)
custom(message: string)

Usage

const Logger = require('masklogger-node');
const path = require('path');

// Define file transport
const fileTransport = new Logger.FileTransport({
  filename: path.join(__dirname, 'combined.log'),
  level: Logger.LogLevelText.ERROR,
});

// Define console transport
const consoleTransport = new Logger.ConsoleTransport();

// Create logger with defined transports
const logger = new Logger.CustomLogger({ transports: [consoleTransport, fileTransport] });

Features

1) Easy to configure 2) Lightweight 3) Supports different colors 4) Supports file write

1.0.9

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago