logry
v2.1.6
Published
π Logging built for humans, everywhere JavaScript runs.
Maintainers
Readme
Console-first, native, and universal logging for JavaScript.
A modular pipeline for structured and extensible log flows.
Built for human-readable logs first, not added later.
Features
- π Runtime-agnostic β consistent logging across all JavaScript runtimes, built on the native console.
- π Hook-based pipeline β a composable logging flow, fully customizable with hooks and plugins.
- π¨ Render & styling β fine-grained control over layout and visual presentation.
Installation
# npm
npm install logry
# yarn
yarn add logry
# pnpm
pnpm add logryOr load it directly from a CDN:
import { logry } from "https://cdn.jsdelivr.net/npm/logry/+esm";Quick Start
The examples below work wherever JavaScript runs.
Create a logger
- Create a logger instance for consistent configuration across your application.
import { logry } from "logry";
const logger = logry();
logger.error("Authentication failed.");Standalone logging
- Use standalone methods for simple, one-off logs.
import { error } from "logry";
error("Unexpected error.");Configuration
Configure a logger when creating it, or adjust behavior for a single log entry.
- Create-time configuration
const logger = logry({
id: "my-logger", // Logger identity
level: "trace", // Minimum log level
scope: ["api", "auth"], // Default scope
context: { ver: "1.2.1" }, // Shared context for all logs
preset: "pretty", // Preset for default behavior
// Pipeline configurations
normalizeConfig: { meta: { errorStackLines: 5 } },
formatConfig: { timestamp: { format: "iso" } },
renderConfig: { message: { prefix: "β‘οΈ ", marginAfter: 1 } },
printConfig: { consoleMode: "log", lineBreaksAfter: 1 },
});- Runtime options
logger.warn("A msg.", { scope: "login", printConfig: { lineBreaksBefore: 2 } });Method overloads
Log methods support flexible argument patterns:
// log(message, options?)
log("Message", options);
// log(meta, options?)
log({ key: "value" }, options);
// log(message, meta, options?)
log("Message", { key: "value" }, options);Hooks & Plugins
Logry is built around a hook-based pipeline,
making it easy to customize behavior or build plugins.
Official Plugins
- Discord plugin β send logs to Discord via webhooks
import { discordPlugin } from "logry/plugins";
logger.use(discordPlugin("https://discord.com/api/webhooks/13869..."));More official plugins are under development.
