v1.0.0 • Production Ready

Professional logging
for Node.js

Beautiful console output, comprehensive file logging, and extensive customization. Zero dependencies. Pure performance.

1,000+
Active Users

Everything you need

Built for modern applications with performance and developer experience in mind

High Performance

50,000+ ops/sec with async file I/O and smart filtering

Beautiful Output

Color-coded levels, centered badges, and rich data display

File Logging

Text, JSON, structured formats with automatic rotation

Structured Logging

JSON output for log aggregation and analysis tools

Performance Monitoring

Built-in timers, profiling, and memory tracking

Type Safe

Full TypeScript support with complete type definitions

Quick Installation

npm install @millosaurs/prettylogs

Why PrettyLogs?

See how PrettyLogs compares to other popular logging libraries

FeaturePrettyLogsWinstonPinoBunyan
Zero Dependencies
Beautiful Console Output
TypeScript Native
File Rotation
Performance (ops/sec)50,000+15,00060,00020,000
Easy Configuration
Child Loggers

Basic Usage

Get started with PrettyLogs in seconds. Import the logger and start logging beautiful, structured messages.

import { logger } from "@millosaurs/prettylogs";

// Simple logging
logger.info("Application started successfully");
logger.debug("Loading configuration files");
logger.warn("Memory usage is at 85%", { usage: "85%", threshold: "80%" });
logger.error("Database connection failed", { host: "localhost", port: 5432 });
logger.success("User authentication completed", {
  userId: 123,
  email: "john@example.com",
});
logger.trace("Entering function validateUser()");
Custom configuration screenshot
Custom configuration screenshot

Custom Configuration

Create custom loggers with your preferred settings. Configure timestamps, file output, colors, and log levels.

import { createLogger } from "@millosaurs/prettylogs";

const customLogger = createLogger({
  timestamps: true,
  logFile: "./logs/app.log",
  colorize: true,
  logFormat: "json",
  minLevel: "INFO",
});

customLogger.info("Custom logger message");

Log Levels

TRACE

Detailed trace information

DEBUG

Debug information

INFO

General information

WARN

Warning messages

ERROR

Error messages

FATAL

Fatal errors

SUCCESS

Success messages

Advanced Features

Everything you need for production-grade logging

File Logging & Rotation

const logger = createLogger({
  logFile: "./logs/app.log",
  maxFileSize: 50 * 1024 * 1024, // 50MB
  maxFiles: 10,
  logFormat: "json",
  async: true,
  bufferSize: 100,
  flushInterval: 1000,
});

Performance Monitoring

// Simple timers
logger.time("database-query");
const result = await database.query("SELECT * FROM users");
logger.timeEnd("database-query");

// Functional timers
const stopTimer = logger.startTimer("api-request");
const response = await fetch("/api/data");
const duration = stopTimer();

Child Loggers

const logger = createLogger();

// Create namespaced logger
const userLogger = logger.child("user-service");
userLogger.info("Processing request");

// With correlation IDs
const requestLogger = logger.child(`req-${Date.now()}`);
requestLogger.info("Request started");

// Chain child loggers
const dbLogger = userLogger.child("database");

Rich Data Display

// Display tables
const users = [
  { id: 1, name: "John", active: true },
  { id: 2, name: "Jane", active: false }
];
logger.table(users);

// Pretty JSON
logger.json(complexObject, "DEBUG");

// Box messages
logger.box("Server ready!");

Web Server Integration

Perfect for Express, Fastify, and other Node.js web frameworks. Add request logging, error tracking, and performance monitoring.

import express from "express";
import { createLogger } from "@millosaurs/prettylogs";

const logger = createLogger({
  logFile: "./logs/server.log",
  timestamps: true,
  logFormat: "json",
});

const app = express();

// Request logging middleware
app.use((req, res, next) => {
  const requestLogger = logger.child(`req-${Date.now()}`);

  requestLogger.info("Incoming request", {
    method: req.method,
    url: req.originalUrl,
    ip: req.ip,
  });

  req.logger = requestLogger;
  next();
});

app.get("/users", async (req, res) => {
  const timer = req.logger.startTimer("fetch-users");

  try {
    const users = await getUsersFromDatabase();
    const duration = timer();

    req.logger.success("Users fetched", {
      count: users.length,
      duration,
    });

    res.json(users);
  } catch (error) {
    req.logger.error("Failed to fetch users", {
      error: error.message,
    });
    res.status(500).json({ error: "Internal server error" });
  }
});
Custom configuration screenshot

Production Best Practices

High-Performance Setup

const logger = createLogger({
  // Optimize for production
  colorize: false,
  prettyPrint: false,
  logFormat: "json",
  async: true,
  bufferSize: 500,
  minLevel: "INFO",

  // File management
  logFile: "./logs/app.log",
  maxFileSize: 100 * 1024 * 1024, // 100MB
  maxFiles: 20,
});

Graceful Shutdown

process.on("SIGTERM", async () => {
  logger.info("Shutting down gracefully");
  await logger.flush();
  await logger.close();
  process.exit(0);
});

process.on("uncaughtException", (error) => {
  logger.fatal("Uncaught exception", {
    message: error.message,
    stack: error.stack,
  });
});

Frequently Asked Questions

Built for Performance

50,000+
Operations/sec
Zero
Dependencies
< 1ms
Average latency
100%
Type coverage

Ready to get started?

Install PrettyLogs now and start building better logging for your applications.