lit-logger

1.0.3 • Public • Published


Logger

A flexible logging and file management system for javascript applications.

◦ Developed with the software and tools listed below.

TypeScript Bun Node.js

GitHub top language GitHub code size in bytes GitHub commit activity GitHub last commit

📒 Table of Contents

📍 Overview

This flexible logging and file management system offers features such as logging with different severity levels, automated log file management including rotation, and custom configuration options. Developers can easily integrate and customize this system for efficient log handling in their applications. Soon to be available on npm.

📄 Usage

   import {Logger, FileLogger} from "lit-logger"
   const log = new Logger({
      formatTime: '24h',
   });

   const flog = new FileLogger({
 	formatTime: "dateTime" ,
 	indent: true,
 	fileType: "json",
 	fileName: "log",
 	dest: "./logs"
   });

   log.info({ blah: true })
   flog.warn("This is interesting")
Option Logger (default) FileLogger(default) Options Description
formatTime 'dateTime' 'dateTime' 'isoTime', 'dateTime', '12h', '24h' Time format for log timestamps.
indent NA false boolean Whether to indent log messages.
fileType NA 'txt' 'json', 'txt' File type for log files.
fileName NA 'log' Any string Name of the log file (without extension).
dest NA './logs' Any valid file path Destination directory for log files.

Note: When setting the formatTime option, you can choose from the following values:

  • 'isoTime': ISO 8601 format (e.g., "2023-09-20T15:30:45.123Z").
  • 'dateTime': Date and time format (e.g., "9/20/2023, 3:30:45 PM").
  • '12h': 12-hour time format with AM/PM (e.g., "3:30:45.123 PM").
  • '24h': 24-hour time format (e.g., "15:30:45.123").

Please make sure to use these options accordingly when configuring your Logger and FileLogger instances.

Log Levels

  • info: Informational messages.
  • warn: Warning messages.
  • error: Error messages.
  • debug: Debugging messages.

These log levels are available for both Logger and FileLogger as methods.

⚙️ Features

  1. Logging : Provides logging functionality with support for various log levels, including debug, info, warn, error, and custom levels.
  2. Custom Configuration : Allows users to configure log formatting, timestamp format, and log output destinations.
  3. File Logging : Supports logging to files, enabling the storage and management of log data.
  4. Log Rotation : Automatically manages log files by rotating them based on size or time intervals.
  5. Flexible Integration : Designed for easy integration into Node.js applications and libraries.
  6. Customizable Themes : Provides options to customize log message themes, including colors and formatting.
  7. Error Handling : Includes robust error handling to gracefully manage exceptions and errors.
  8. Size-based File Splitting : Can split log files when they exceed a specified size limit.
  9. Timestamp Formats : Supports different timestamp formats, such as ISO 8601, 12-hour, and 24-hour formats.
  10. Log Output Destinations : Allows developers to configure log output destinations, including the console and log files.
  11. Dynamic Log Levels : Provides flexibility to dynamically adjust log levels during runtime.
  12. Efficient Log Storage : Efficiently stores log data with customizable formatting options.

🤝 Contributing

Contributions are always welcome! Please follow these steps:

  1. Fork the project repository. This creates a copy of the project on your account that you can modify without affecting the original project.
  2. Clone the forked repository to your local machine using a Git client like Git or GitHub Desktop.
  3. Create a new branch with a descriptive name (e.g., new-feature-branch or bugfix-issue-123).
git checkout -b new-feature-branch
  1. Make changes to the project's codebase.
  2. Commit your changes to your local branch with a clear commit message that explains the changes you've made.
git commit -m 'Implemented new feature.'
  1. Push your changes to your forked repository on GitHub using the following command
git push origin new-feature-branch
  1. Create a new pull request to the original project repository. In the pull request, describe the changes you've made and why they're necessary. The project maintainers will review your changes and provide feedback or merge them into the main branch.

👏 Acknowledgments

  • ℹ️ ChatGPT for making this Readme 🥲

Package Sidebar

Install

npm i lit-logger

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

81.1 kB

Total Files

14

Last publish

Collaborators

  • priyankishore