A lightweight, elegant TypeScript logger with color-coded output and timestamps.
- 🎨 Color-coded log levels - Easy visual distinction between log types
- ⏱️ High-precision timestamps - Millisecond accuracy (HH:MM:SS.mmm)
- 📦 Multiple log levels - INFO, WARN, ERROR, DEBUG, SUCCESS, FATAL, TRACE
- 🏷️ Area/Context tags - Organize logs by module or component
- 🎯 Clean formatting - Tab-aligned columns for consistent readability
- 💪 TypeScript support - Fully typed for better developer experience
bun installimport log from "./src/index";
// Simple logs
log.info("Server started on port 3000");
log.warn("Memory usage is high");
log.error("Database connection failed");
log.debug("Debugging information");
log.success("Task completed successfully");
log.fatal("Critical system failure");
log.trace("Detailed trace information");// Logs with categorized areas
log.info("Order confirmed: order_789", "orders");
log.warn("Stripe API slow response: 145ms", "payments");
log.error("Database connection failed", "database");
log.debug("Calling Stripe API, attempt 1", "payments");
log.success("Payment successful, charge_ch_abc", "payments");
log.fatal("Critical system failure", "system");
log.trace("Variable value: 42", "debugger");// Using the base log method with custom level
log.log({
level: "info",
message: "Custom log message",
area: "custom-module"
});08:45:54.564 INFO [orders] Order confirmed: order_789
08:45:54.566 WARN [payments] Stripe API slow response: 145ms
08:45:54.566 DEBUG [payments] Calling Stripe API, attempt 1
08:45:54.567 ERROR [database] Connection timeout
08:45:54.568 SUCCESS [payments] Payment successful, charge_ch_abc
| Level | Color | Use Case |
|---|---|---|
| INFO | Cyan | General information and status updates |
| WARN | Yellow | Warning messages and potential issues |
| ERROR | Red | Error messages and failures |
| DEBUG | Green | Debug information during development |
| SUCCESS | Green | Successful operations |
| FATAL | Red/Bold | Critical errors requiring immediate attention |
| TRACE | Magenta | Detailed trace information for debugging |
Log an informational message.
Log a warning message.
Log an error message.
Log a debug message.
Log a success message.
Log a fatal error message with emphasized styling.
Log a trace message for detailed debugging.
Base logging method with custom log level.
Parameters:
level- The log level type (info, warn, error, debug, success, fatal, trace)message- The message to logarea- Optional area/context to categorize the log
bun run test/index.tsbun build src/index.ts --outdir ./dist- chalk - Terminal string styling
MIT
Contributions are welcome! Please feel free to submit a Pull Request.