1.0.6 • Published 7 months ago

@kkmb/logger v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Logger Documentation

Overview

The Logger class is a flexible logging utility designed to work in both frontend (browser) and backend (Node.js) environments.


Features

  1. Logging Levels: Supports various log levels:

    • info
    • warn
    • error
    • debug
    • trace
  2. Environment Detection:

    • Automatically adjusts behavior for frontend (browser) or backend (Node.js).
  1. Colorized Output:
    • Uses ANSI escape codes in Node.js.
    • Applies CSS styles in the browser.

Installation

npm install @kkmb/logger

Usage

  • Commonjs
const {Logger} = require( '@kkmb/logger');
const log = new Logger();
  • ESM
import {Logger} from '@kkmb/logger';
const log = new Logger();

API Reference

info(...message: any[]): void

Logs an informational message.

warn(...message: any[]): void

Logs a warning message.

error(...message: any[]): void

Logs an error message.

debug(...message: any[]): void

Logs a debug message.

trace(...message: any[]): void

Logs a trace message.


Examples

Example 1: Basic Logging

logger.info("This is info log !");
logger.error("This is error log !");
logger.warn("This is warning log !");
logger.debug("This is debug log !");
logger.trace("This is trace log !");

Compatibility

Frontend (Browser)

  • Colorized output using CSS styles.
  • Dynamic message formatting.

Backend (Node.js)

  • Colorized output using ANSI escape codes.
  • Dynamic message formatting.

Future Enhancements

  • Add support for additional dynamic placeholders.
  • Enable log rotation for file-based logging.
  • Integrate with external logging services.

License

MIT License

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

12 months ago

1.0.0

12 months ago