npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

logify-fa

v3.0.0

Published

Logify-fa is a lightweight, color-coded logging utility for Node.js and browser applications, supporting Persian date formatting and file logging.

Downloads

97

Readme

Logify-fa

Logify-fa is a powerful yet lightweight logging library designed for both Node.js and browser applications. It features color-coded log levels, customizable log messages, supports Persian (Jalaali) date formatting, and includes file logging capabilities. This package makes it easier to maintain consistent and informative logs across different environments.

Features

  • Color-Coded Log Levels: Quickly identify log levels with color-coded messages.
  • Persian Date Formatting: Automatically includes Persian (Jalaali) dates in log messages.
  • Customizable Log Levels: Control which log levels are shown based on your environment.
  • Support for Metadata: Attach additional information to log messages to provide more context.
  • File Logging: Logs are automatically saved to a file in the logger directory, ensuring that you have persistent log records.
  • Universal Compatibility: Works seamlessly in both Node.js and browser environments.

Installation

You can install Logify-fa via npm:

npm install logify-fa

Or using yarn:

yarn add logify-fa

Or using pnpm:

pnpm install logify-fa

Usage

Creating Logger Instances

Import the factory function and create logger instances with custom settings:

import createLogger from 'logify-fa';

const logger = createLogger({
    level: 'debug', // Minimum log level to capture
    filename: 'path/to/your/logs.log' // File to save the logs
});

// Example of logging
logger.info("This is an info message with Persian date");
logger.error("This is an error message with Persian date");

Log Levels

Logify-fa supports four log levels, each with its own color for easy identification:

  • debug: Blue
  • info: Green
  • warn: Yellow
  • error: Red

Logging with Metadata

Attach metadata to your log messages for more detailed logging:

logger.debug("Debugging info", { userId: 123, operation: "update" });
logger.error("Error occurred", { errorCode: 500, errorMessage: "Internal Server Error" });

File Logging

All log messages are automatically saved to the specified file in the logger directory:

[1402-12-11] [INFO]: This is an info message with Persian date
[1402-12-11] [ERROR]: This is an error message with Persian date

Configuration

Customize your logger instances based on your needs:

  • Log Level: Set the minimum log level to display.
  • File Path: Specify the path to the file where logs should be saved.

Contributing

Contributions are welcome! If you find a bug or have a feature request, please create an issue or submit a pull request on GitHub.

### Key Changes
- **Creating Logger Instances**: Added a section to guide users on how to create their own logger instances using the factory function, which allows custom settings.
- **Configuration**: Expanded the configuration section to cover more on how users can customize their logger instances.
- **Example Code**: Updated the code examples to reflect the usage of the new logger creation approach.

This updated README should help users understand how to effectively use and integrate the `Logify-fa` logging library into their projects with custom configurations.