1.0.4 • Published 6 months ago
env-log-manager v1.0.4
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 totrue
(logging disabled).
Methods
developmentLog(message: string): void
- Logs messages for development when
disableLogging
is set totrue
.
- Logs messages for development when
productionLog(message: string): void
- Logs messages for production when
disableLogging
is set tofalse
.
- Logs messages for production when
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
- keval vyas
- GitLab: Your GitLab Profile
Enjoy using env-log-manager
! If you find it helpful, consider giving the repository a star!