logluxe
v1.0.3
Published
Tiny, zero-dependency, TypeScript-first logging utility. Drop-in console.* replacement with beautiful colored logs.
Maintainers
Readme
🎨 Logluxe
Tiny, zero-dependency, TypeScript-first logging utility
"Install once, never think about logs again."
A drop-in replacement for console.* with beautiful colored logs, smart defaults, and zero configuration required.
✨ Features
- 🪶 Zero dependencies - Pure TypeScript
- 📦 < 2KB minified - Tiny footprint
- 🌳 Tree-shakable - Import only what you need
- 🔷 TypeScript-first - Full type safety
- 📦 ESM + CJS - Works everywhere
- 🌍 Universal - Node.js, Browser, Deno, Bun
- 🎨 Beautiful colors - ANSI in terminal, CSS in browser
- 🔧 Zero config - Works out of the box
� Documentation
📖 Full Documentation: https://logluxe.vercel.app/
�📥 Installation
npm install logluxe
# or
yarn add logluxe
# or
pnpm add logluxe🚀 Quick Start
Option 1: Drop-in Console Patch (Zero Changes)
// Just import this at the top of your entry file
import "logluxe/patch";
// Now all console methods are enhanced automatically!
console.log("Regular log");
console.info("Info message"); // ℹ Info message
console.warn("Warning!"); // ⚠ Warning!
console.error("Error!"); // ✖ Error!
console.debug("Debug info"); // ● Debug infoOption 2: Semantic Logger API
import log from "logluxe";
log.success("Build complete"); // ✔ Build complete
log.error("DB failed"); // ✖ DB failed
log.warn("Memory high"); // ⚠ Memory high
log.info("Server started"); // ℹ Server started
log.debug("Payload received"); // ● Payload received📚 Full API
Semantic Logging
log.success("Operation completed");
log.error("Something went wrong");
log.warn("Deprecated feature used");
log.info("Server listening on :3000");
log.debug("Request payload:", data);Manual Color Control
log.color("Custom text", "red");
log.color("HEX color", "#ff00ff");
log.color("RGB color", "rgb(0,255,0)");Chainable Style Builder
log.paint("CRITICAL")
.white()
.bgRed()
.bold()
.underline()
.print();
log.paint("Muted text")
.gray()
.dim()
.italic()
.print();Available styles:
- Colors:
black(),red(),green(),yellow(),blue(),magenta(),cyan(),white(),gray() - Bright:
brightRed(),brightGreen(),brightYellow(),brightBlue(),brightMagenta(),brightCyan(),brightWhite() - Backgrounds:
bgBlack(),bgRed(),bgGreen(),bgYellow(),bgBlue(),bgMagenta(),bgCyan(),bgWhite() - Styles:
bold(),dim(),italic(),underline(),inverse(),strikethrough()
Text Effects
log.gradient("Welcome to the app!");
log.rainbow("Hello World!");
log.neon("Server Online", "#00ff00");Inline Color Tags
log.inline("[red]ERROR[/red] File not found");
log.inline("Status: [green]RUNNING[/green]");
log.inline("[cyan]User:[/cyan] [yellow]John[/yellow]");Background & Highlight
log.bg("CRITICAL", "white", "red");
log.bg("SUCCESS", "black", "green");
log.highlight("User John logged in", "John", "cyan");Environment-Aware Logging
log.dev("Only in development"); // Shows when NODE_ENV === 'development'
log.prod("Only in production"); // Shows when NODE_ENV === 'production'
log.once("key", "Printed once"); // Only prints the first timeFramework Aliases
log.react("Component mounted"); // ⚛️ Component mounted
log.server("API started"); // 🖥️ API started
log.client("Hydrated"); // 🌐 HydratedPerformance Logger
// Synchronous
const result = log.perf("DB Query", () => runQuery());
// ⏱ DB Query took 42.3ms
// Async
const data = await log.perf("Fetch API", async () => fetchData());
// ⏱ Fetch API took 120.5msLog Grouping
log.group("User Signup");
log.info("Validate email");
log.info("Check username");
log.success("User created");
log.end(); // or log.groupEnd()Smart Error Formatting
try {
throw new Error("Database connection failed");
} catch (error) {
log.error("API failed", error);
// Automatically formats with:
// - Error name and message
// - Colored stack trace
// - Additional error properties
}Utilities
log.banner("My CLI Tool"); // Creates a boxed banner
log.previewColors(); // Shows all available colors
log.reset(); // Reset all settings⚙️ Configuration
import log from "logluxe";
// Disable colors
log.noColor();
// Mute all output
log.mute();
log.unmute();
// Change theme
log.setTheme("dark"); // 'default' | 'dark' | 'minimal' | 'neon'
// Configure options
log.configure({
colors: true, // Enable/disable colors
icons: true, // Show icons/emojis
labels: false, // Show level labels (INFO, WARN, etc.)
theme: "default", // Theme name
level: "debug", // Minimum log level
timestamp: false, // Show timestamps
});
// Add custom presets
log.addPreset("critical", {
color: "white",
bg: "red",
bold: true,
icon: "🔴"
});🎨 Themes
Default
Balanced colors with icons, works great in most terminals.
Dark
Optimized for dark terminals with brighter colors.
Minimal
No icons, subtle colors, clean output.
Neon
Vibrant colors with bold styling for maximum visibility.
🌍 Environment Detection
Logluxe automatically detects:
- Runtime: Node.js, Bun, Deno, Browser
- TTY: Disables colors when not in a terminal
- CI: Disables colors in CI environments
- NO_COLOR: Respects the
NO_COLORenvironment variable - FORCE_COLOR: Forces colors when set
📦 Exports
// Default logger instance
import log from "logluxe";
// Create custom logger
import { createLogger } from "logluxe";
const myLog = createLogger({ theme: "neon" });
// Individual utilities
import {
colorize,
stripAnsi,
formatError,
gradientText,
isBrowser,
isDev,
} from "logluxe";🔧 Advanced Usage
Create Multiple Logger Instances
import { createLogger } from "logluxe";
const apiLogger = createLogger({
theme: "minimal",
labels: true
});
const debugLogger = createLogger({
theme: "neon",
level: "debug"
});Direct Style Functions
import { colorize, quickColor, quickBg } from "logluxe";
const redText = quickColor("Error!", "red");
const highlighted = quickBg("Important", "red", "white");Restore Original Console
import "logluxe/patch";
import { unpatch } from "logluxe/patch";
// Later, if needed
unpatch(); // Restores original console methods💡 Package Name Ideas
If logluxe is taken, here are alternatives:
@log/luxelogcharmkonsolelogpaintprettylogslogcandychromaloglogflairsnaploglogshine
📄 License
MIT © Your Name
Made with ❤️ for developers who love beautiful logs.
