0.5.0 • Published 7 months ago

simple-log-helper v0.5.0

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

simple-log-helper

A lightweight logging utility to manage logs for different environments (development and production). Easily switch logging on or off based on your needs.

Installation

To install the package, use:

npm install simple-log-helper

Usage

Importing the Library

import { LogHelper } from "simple-log-helper";

const logHelper = new LogHelper();
logHelper.developmentLog("This is a development log.");
logHelper.productionLog("This is a production log.");

Class: LogHelper

new LogHelper(enableProductionMode: boolean = false)
  • Parameters:

    • enableProductionMode (optional): A boolean value to toggle production mode. Defaults to false (production mode Off).
  • notations:

    • #P : Production mode
    • #D : Development mode
    • $P : starting of function
    • P$ : End of function

Methods

  1. developmentLog(message: string): void

    • Logs messages for development when enableProductionMode is set to false.
  2. productionLog(message: string): void

    • Logs messages for production when enableProductionMode is set to true.

Example

Development mode: on

  • All logs will get printed in this mode
const logHelper = new LogHelper(); // Development mode on by default
logHelper.developmentLog("This is a development log"); // #D 1/23/2025, 4:51:45 PM - This is a development log
logHelper.productionLog("This is a production log"); // #P 1/23/2025, 4:51:45 PM - This is a production log

Production mode: on

  • Only development logs will not get printed in this mode
const logHelper = new LogHelper(true); // enable production mode
logHelper.developmentLog("This is a development log"); // Logs will not get printed.
logHelper.productionLog("This is a production log"); // #P 1/23/2025, 4:51:45 PM - This is a production log
logHelper.fnInitLog('Function execution started'); // $P 1/23/2025, 4:51:45 PM - Function execution started
logHelper.fnEndLog('Function execution completed'); // P$ 1/23/2025, 4:51:45 PM - Function execution completed

TypeScript Support

This package includes TypeScript definitions (.d.ts) to ensure compatibility and autocompletion in TypeScript projects.

Contributing

Contributions are welcome! If you have suggestions or find issues, feel free to open a pull request or file an issue on GitLab.

License

This project is licensed under the MIT License. See the LICENSE file for details.


Author

Enjoy using simple-log-helper! If you find it helpful, consider giving the repository a star!

0.5.0

7 months ago

0.4.0

7 months ago

0.3.0

7 months ago

0.2.0

7 months ago

0.1.0

7 months ago

0.0.1

7 months ago

1.0.0

8 months ago