New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

pie-logger

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pie-logger

A feature-rich logger for Node.js

latest
npmnpm
Version
1.0.3
Version published
Maintainers
0
Created
Source

PieLogger

PieLogger is a feature-rich, customizable, and lightweight logger for Node.js applications. It supports multiple log levels, structured logging, colored console output, and file-based logging.

Installation

Install the package using npm:

npm install pie-logger

Usage

1. Basic Setup

import { PieLogger } from "pie-logger";

const logger = new PieLogger({ loggerName: "MyAppLogger" });

logger.info("This is an info message.");
logger.error("This is an error message.", { error: "Sample Error" });

2. Available Log Levels

Log LevelMethodExample
Debuglogger.debug()logger.debug("Debugging the process.");
Infologger.info()logger.info("Informational message.");
Warninglogger.warning()logger.warning("This is a warning.");
Errorlogger.error()logger.error("An error occurred.");
Criticallogger.critical()logger.critical("Critical failure!");

Example:

logger.debug("Debugging a process.");
logger.info("This is an informational message.");
logger.warning("This is a warning message.");
logger.error("This is an error message.", { errorCode: 500 });
logger.critical("Critical failure!", { service: "Database" });

3. Configuration Options

You can customize PieLogger with several configuration options:

const logger = new PieLogger({
  loggerName: "MyAppLogger", // Name of the logger
  logToFile: true, // Enable/Disable file-based logging (default: true)
  logDirectory: "logs", // Directory for log files (default: 'logs')
  minimumLogLevel: PieLogLevel.DEBUG, // Minimum log level (default: INFO)
  colorful: true, // Enable colored console output (default: true)
});

4. Structured Logging

PieLogger supports structured logging with additional details:

logger.info("User logged in", { userId: 123, action: "login" });
logger.error("Error processing request", {
  endpoint: "/api/data",
  errorCode: 400,
});

5. File Logging

Logs are automatically saved to files when logToFile is enabled. Files are rotated when they reach the size limit (32MB by default).

License

This package is open-source and available under the MIT License.

Author

Developed by Chanpreet Singh & Himanshu Upreti.

Contributions

Feel free to fork, contribute, or submit issues on the GitHub repository. 😊

This README can be placed in a README.md file in your project and will be displayed on your package's npm page. Adjust the GitHub repository link and other details as needed.

Keywords

logger

FAQs

Package last updated on 02 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts