An elegant, fast, and type-safe logging middleware for Elysia.js. Take absolute control of your request feeds with colorized square console streams and structured file records.
Fitted precisely to Elysia's lifecycle events. Zero setup with high-resolution execution timelines and zero overhead.
Color-coded methods and HTTP status symbols (2xx/3xx/4xx/5xx) so your eyes track health in real time.
Autocreates log folders and writes organized chronological entries to disk for production reviews.
Resolves and appends inbound client IPs, including fallbacks for proxy servers behind standard cloud loads.
Bypass request logging for system endpoints (like /health, /metrics, or assets) to keep logs clean.
Engineered in TypeScript. Ships with type auto-completion and rigid validation for all customization setups.
Simply load and register the logger() middleware into your Elysia chain. It begins tracking your incoming web traffic instantly, printing clear, beautifully aligned console lines with zero custom parameters required.
Want specific formats or filters? Just supply your properties to the logger(...) options.
import { Elysia } from "elysia"; import { logger } from "@rasla/logify"; const app = new Elysia() .use(logger()) .get("/", () => "🦊 Hello World!") .listen(3000); console.log("🦊 Elysia server running at localhost:3000");
import { initializeLogger, debug, info, warn, error } from "@rasla/logify"; // Configure once in your entry file initializeLogger({ level: "debug", file: true, filePath: "./logs/app.log" }); // Execute log commands anywhere in your application debug("Init db connection pool..."); info("System health checked: OK"); warn("Database query latency: 154ms"); error("Failed to retrieve user ID: 219");
Logify packs a global instance. Instead of injecting custom middleware variables through domain components, simply instantiate Logify's settings once in your setup file via initializeLogger(...).
You can then import clean functions directly: debug(), info(), warn(), and error(). Keep your layers separated and imports simple.
Configure outputs, toggle disk writes, bypass custom route endpoints, and customize terminal strings using rich, modular formatting tokens.
Explore a reference options structure you can feed directly into your initialization configurations:
{
// Console logs (default: true)
console: true,
// File logging (default: false)
file: true,
filePath: './logs/app.log',
// Log level limit (default: 'info')
level: 'debug', // 'debug' | 'info' | 'warn' | 'error'
// Skip routes (avoid health or assets spam)
skip: ['/health', '/metrics'],
// Display client IP (default: false)
includeIp: true,
// String format tokens (see right playground!)
format: '[{timestamp}] {level} [{method}] {path} - {statusCode} {duration}ms'
}
Build your custom terminal output view. Modify the format string below, or click tokens to append them, and see the immediate output.
Available Tokens (Click to append)
| Token | Resolves To | Terminal Preview Example |
|---|---|---|
| {timestamp} | ISO-8601 formatted global time string | 2026-05-21T17:40:00.123Z |
| {level} | Colorized severity tag (INFO, WARN, ERROR) | INFO |
| {method} | HTTP request verb (GET, POST, PUT, DELETE) | GET |
| {path} | Target endpoint relative pathname | /api/users |
| {statusCode} | Dynamic HTTP status code (green/yellow/red) | 200 |
| {duration} | Request execution time measured in ms | 8.4ms |
| {ip} | The client IP resolve (e.g. proxy header fallback) | 127.0.0.1 |