A beautiful, fast, and type-safe logging middleware for Node.js web applications. Get instant insights into your HTTP requests with colorized console output and structured file logging.
This monorepo contains the following packages:
- @rasla/logify - Logging middleware for Elysia.js
- @rasla/express-logify - Logging middleware for Express.js
- 🎨 Beautiful console output with color-coded log levels
- ⚡ Zero-config with smart defaults
- 📊 Request duration and status code tracking
- 🌐 IP address logging with proxy support
- 📝 Structured logging with TypeScript support
- 🎯 Path-based request filtering
- 🔄 Automatic log directory creation
- 🎛️ Fully customizable log formats
- 🌍 Global logger instance for application-wide logging
- 📝 Convenient logging functions: debug(), info(), warn(), and error()
Choose the package that matches your framework:
bun add @rasla/logifynpm install @rasla/express-logify
# or
yarn add @rasla/express-logify
# or
pnpm add @rasla/express-logifyimport { Elysia } from "elysia";
import { logger } from "@rasla/logify";
const app = new Elysia()
.use(logger())
.get("/", () => "Hello World!")
.listen(3000);import express from "express";
import { logger } from "@rasla/express-logify";
const app = express();
app.use(logger());
app.get("/", (req, res) => res.send("Hello World!"));
app.listen(3000);Both packages now include a global logger that can be accessed from anywhere in your application:
// Elysia.js
import {
initializeLogger,
debug,
info,
warn,
error
} from "@rasla/logify";
// Express.js
import {
initializeLogger,
debug,
info,
warn,
error
} from "@rasla/express-logify";
// Configure once at startup
initializeLogger({
level: "debug",
file: true,
filePath: "./logs/app.log"
});
// Use anywhere in your code
debug("This is a debug message");
info("This is an info message");
warn("This is a warning message");
error("This is an error message");
| `{statusCode}` | HTTP status | `200`, `404` |
| `{duration}` | Request time | `123ms` |
| `{ip}` | Client IP | `127.0.0.1` |Check out the examples in each package:
Contributions are welcome! Please feel free to submit a Pull Request.
Both packages support the same configuration options:
{
// Console logging (default: true)
console: true,
// File logging (default: false)
file: true,
filePath: './logs/app.log',
// Log level (default: "info")
level: 'debug', // "debug" | "info" | "warn" | "error"
// Skip certain paths
skip: ['/health', '/metrics'],
// Include IP address (default: false)
includeIp: true,
// Custom format (see Format Tokens below)
format: '[{timestamp}] {level} [{method}] {path} - {statusCode} {duration}ms{ip}',
}Customize your log format using these tokens:
| Token | Description | Example |
|---|---|---|
{timestamp} |
ISO timestamp | 2024-12-03T17:48:54.721Z |
{level} |
Log level | INFO, ERROR |
{method} |
HTTP method | GET, POST |
{path} |
Request path | /api/users |
{statusCode} |
HTTP status | 200, 404 |
{duration} |
Request time | 123ms |
{ip} |
Client IP | 127.0.0.1 |
Check out the examples in each package:
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - Created by 0xRasla