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

v2.1.0

Published

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

Downloads

106

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, and supports Persian (Jalaali) date formatting out of the box. 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.
  • Universal Compatibility: Works seamlessly in both Node.js and browser environments.

Installation

You can install logify-fa via npm:

npm install logify-fa

yarn

yarn add logify-fa

pnpm

pnpm install logify-fa

Usage

Basic Setup

First, import the logger and start logging:


import { clientLogger, serverLogger } from 'logify-fa';

// Example of client-side logging
clientLogger.info("This is an info message from the client");

// Example of server-side logging
serverLogger.warn("This is a warning message from the server");

Log Levels

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

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

You can control the minimum log level output by setting the level in the logger's constructor:


import { clientLogger } from 'logify-fa';
// Only logs 'warn' and 'error' messages
const logger = new clientLogger("warn");
logger.debug("This debug message will not be logged");
logger.error("This error message will be logged");

Logging with Metadata

You can attach metadata to your log messages for more detailed logging:

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

Persian Date in Logs

All log messages automatically include the current date in the Persian calendar:

clientLogger.info("This is an info message");
// Output: [1402-12-11] [INFO]: This is an info message

Configuration

logify-fa can be configured to match your specific logging requirements:

  • Log Level: Set the minimum log level to display (default is info).
  • Metadata: Include additional data with each log entry.
  • Persian Date: Automatically adds Persian date formatting to each log entry.

Webpack Configuration

If you are using logify-fa in a project with Webpack, here’s a basic configuration for bundling the package:

const path = require("path");

module.exports = {
entry: "./src/index.ts",
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
library: "LogifyFa",
libraryTarget: "umd",
globalObject: "this",
},
module: {
rules: [
{
test: /\.ts$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".ts", ".js"],
},
mode: "production",
};

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.