JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q34443F
  • License MIT

A simple function to log single url requests to a server.

Package Exports

  • single-logger
  • single-logger/logger.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (single-logger) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Single Logger

single-logger is a lightweight Node.js logging utility designed to provide simple event logging capabilities. It helps you manage logs in a structured manner and facilitates easy integration into your Node.js applications.

Installation

You can install single-logger using npm:

npm install single-logger

Usage

importing the module

First, import the logger module into your Node.js application:

const logger = require("single-logger");

Logging Events

To log events using single-logger, you can call the 'logEvent functuion:

logger.logEvent(event, level, message);
  • 'event': A descriptive label for the event being logged.

  • level: The severity level of the event (e.g., "INFO", "WARNING", "ERROR").

  • message: The message or details associated with the event.

example:

const event = "app";
const level = "INFO";
const message = "GET request received";
logger.logEvent(event, level, message);

Integration with Event Emitter

single-logger can be integrated with Node.js' built-in Event Emitter or other event-driven architectures for streamlined event logging.

Example integration with Event Emitter:

const events = require("events");
const emitEvent = new events.EventEmitter();

// Define a listener for your events
emitEvent.on("log", (event, level, message) => {
  logger.logEvent(event, level, message);
});

// Emit an event
emitEvent.emit("log", "app", "INFO", "GET request received");

Configuration

You can configure certain aspects of single-logger by modifying the code according to your needs. The following aspects can be customized:

  • log formatting: The way log messages are structured, including the date format and fields order.

  • log directory: The directory structure where log files are stored. By default, logs are saved in the logs/YYYY/MM/ directory structure.

Please refer to the source code for detailed information on how to customize these aspects.

license

This project is developed under the MIT License

About

single-logger is developed and maintained by A. Singleton