1.0.1 • Published 5 months ago

0xlogs v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

0xLogs

0xLogs is a lightweight and configurable logging utility for Node.js applications. It supports JSON parsing, file output, and built-in process event logging to help monitor your app's health and behavior with minimal setup.


šŸ“¦ Installation

npm install 0xlogs

šŸš€ Features

  • Logging with custom levels: info, warn, error, debug
  • Optional JSON formatting
  • File logging support
  • Safe schema validation
  • Auto-handling for:
    • uncaughtException
    • unhandledRejection
    • SIGINT, SIGTERM, exit
    • Warnings and IPC messages

šŸ› ļø Usage

Basic Example

const CreateLog = require("0xlogs");

const log = new CreateLog({
  type: "info",
  filePath: "./logs.txt",
  json: true
});

log("App started", { port: 3000 });

Update Config

log.setConfig({
  type: "error",
  json: false
});

āš™ļø Config Options

OptionTypeDefaultDescription
typeStringinfoLog level (info, warn, error, debug)
filePathStringundefinedPath to output log file (optional)
jsonBooleantrueEnable JSON formatting for logs

šŸ“‚ Built-in Process Logging

When require("0xlogs") is invoked, it automatically logs:

  • Uncaught exceptions and rejections
  • Signals like SIGINT, SIGTERM
  • Process exit events
  • IPC messages (process.send)
  • Warnings

Example logs:

[~] [ERROR] Uncaught Exception: ...
[~] [INFO] Exited Application.
[~] [WARN] A promise rejection was handled asynchronously: ...

šŸ“ File Structure (for contributors)

0xlogs/
ā”œā”€ā”€ lib/
│   ā”œā”€ā”€ index.js        # Combines validation utilities and config types
│   ā”œā”€ā”€ process/
│   │   ā”œā”€ā”€ index.js    # Handles process-level logging
│   ā”œā”€ā”€ types/
│   │   ā”œā”€ā”€ index.js    # Schema definition
│   ā”œā”€ā”€ functions/
│   │   ā”œā”€ā”€ index.js    # Config & path validation
ā”œā”€ā”€ index.js            # Main class (CreateLog)

šŸ“œ License

MIT Ā© 2025

1.0.1

5 months ago

1.0.0

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago