1.0.4 • Published 6 months ago

env-log-manager v1.0.4

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
6 months ago

env-log-manager

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

Features

  • Environment-based logging:
    • Development logs: Displayed when logging is enabled.
    • Production logs: Displayed when logging is disabled.
  • Simple and easy-to-use API.
  • TypeScript support for better development experience.

Installation

To install the package, use:

npm install env-log-manager

Usage

Importing the Library

For TypeScript:

import { LogHelper } from "env-log-manager";

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

For JavaScript:

const { LogHelper } = require("env-log-manager");

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

API

Class: LogHelper

Constructor

new LogHelper(disableLogging: boolean = true)
  • Parameters:
    • disableLogging (optional): A boolean value to toggle logging. Defaults to true (logging disabled).

Methods

  1. developmentLog(message: string): void

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

    • Logs messages for production when disableLogging is set to false.

Example

Development Logging

const logHelper = new LogHelper(); // Logging enabled by default
logHelper.developmentLog("This is a development log");

Production Logging

const logHelper = new LogHelper(false); // Disable development logs
logHelper.productionLog("This is a production log");

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 env-log-manager! If you find it helpful, consider giving the repository a star!

1.0.2

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago