DEV Community

Cover image for Zylog - A Simple Yet Powerful Logger for Node.js
TenE
TenE

Posted on

Zylog - A Simple Yet Powerful Logger for Node.js

Logging is one of the most underrated yet essential parts of building scalable applications. Whether you're debugging, monitoring, or just tracking events, a good logger can make your life way easier.

That’s where Zylog comes in — a lightweight, flexible, and developer-friendly logger built for Node.js.


✨ Why Zylog?

Most logging libraries are either:

  • Too heavy ⚖️
  • Too complex 🤯
  • Or too limited 🚫

Zylog strikes the perfect balance by being:

  • ⚡ Fast and minimal
  • 🎨 Beautiful and colorized logs
  • 🔧 Highly configurable
  • 🧩 Easy to integrate
  • 📁 File logging support

📦 Installation

Install Zylog using your favorite package manager:

npm install zylog
Enter fullscreen mode Exit fullscreen mode

or

pnpm add zylog
Enter fullscreen mode Exit fullscreen mode

or

yarn add zylog
Enter fullscreen mode Exit fullscreen mode

🚀 Quick Start

import { zylog } from "zylog";

zylog.info("Server started");
zylog.warn("This is a warning");
zylog.error("Something went wrong");
Enter fullscreen mode Exit fullscreen mode

🧠 Log Levels

Zylog supports multiple log levels out of the box:

Level Description
info General information
warn Warnings
error Errors
debug Debugging details
zylog.debug("Debugging value:", { userId: 123 });
Enter fullscreen mode Exit fullscreen mode

🎨 Colored Output

Zylog automatically colorizes output based on log levels:

zylog.info("Info message");   // Blue/Green
zylog.warn("Warning message"); // Yellow
zylog.error("Error message"); // Red
Enter fullscreen mode Exit fullscreen mode

No extra setup needed 🔥


⚙️ Configuration

You can fully customize Zylog:

import { Zylog } from "zylog";

const logger = new Zylog({
  level: "debug",
  timestamp: true,
  color: true,
});
Enter fullscreen mode Exit fullscreen mode

🧾 Logging to Files

Want to persist logs? Zylog supports file logging too:

const logger = new Zylog({
  file: {
    path: "./logs/app.log",
  },
});

logger.info("This will be saved to file");
Enter fullscreen mode Exit fullscreen mode

📂 Real-World Examples

1. Express Server Logging

import express from "express";
import { zylog } from "zylog";

const app = express();

app.get("/", (req, res) => {
  zylog.info("Incoming request", { url: req.url });
  res.send("Hello World");
});

app.listen(3000, () => {
  zylog.info("Server running on port 3000");
});
Enter fullscreen mode Exit fullscreen mode

2. Error Handling

try {
  throw new Error("Database failed");
} catch (err) {
  zylog.error("Critical error occurred", err);
}
Enter fullscreen mode Exit fullscreen mode

3. Custom Logger Instance

const logger = new Zylog({
  level: "info",
});

logger.info("Custom logger instance");
Enter fullscreen mode Exit fullscreen mode

4. Debugging Complex Objects

const user = {
  id: 1,
  name: "TenE",
  role: "admin",
};

zylog.debug("User details:", user);
Enter fullscreen mode Exit fullscreen mode

🧩 Advanced Usage

Disable Colors (for production logs)

const logger = new Zylog({
  color: false,
});
Enter fullscreen mode Exit fullscreen mode

Custom Log Format (conceptual)

const logger = new Zylog({
  format: (level, message) => {
    return `[${level.toUpperCase()}]: ${message}`;
  },
});
Enter fullscreen mode Exit fullscreen mode

⚡ Performance

Zylog is built to be:

  • Non-blocking
  • Lightweight
  • Efficient for high-frequency logging

Perfect for:

  • APIs
  • CLI tools
  • Background jobs

🛠️ Use Cases

  • Backend APIs
  • CLI tools
  • Automation scripts
  • Dev debugging
  • Production monitoring

🧑‍💻 Developer Experience

Zylog focuses heavily on DX:

  • Clean API
  • TypeScript support
  • Minimal setup
  • Chainable and intuitive usage

🔮 What's Next?

Some ideas you can build with Zylog:

  • Log dashboards
  • CLI debugging tools
  • Middleware logging systems
  • Monitoring pipelines

💡 Final Thoughts

If you’re tired of bulky logging libraries or messy console logs, Zylog is a clean and powerful alternative.

It gives you:

  • Control
  • Simplicity
  • Performance

All in one package 🚀


⭐ Support

If you like Zylog: https://github.com/teneplaysofficial/zylog/issues

  • ⭐ Star the repo
  • 🐛 Report issues
  • 💡 Suggest features

📌 TL;DR

import { zylog } from "zylog";

zylog.info("Simple. Clean. Powerful.");
Enter fullscreen mode Exit fullscreen mode

Happy logging! 🎉

Top comments (0)