Skip to main content

Rocket Quick Start

Triangular Flag Installation​

npm install logry

or use yarn

yarn add logry

Label Use in plain HTML with this script:

<!-- Use logry in any static HTML page via jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/logry@1.1.2/dist/browser-lite/index.global.min.js"></script>
<script>
logry.info("Hey! I'm here!");
</script>

Sparkles Using Static Logger Methods​

They work instantly, ignore level restrictions, and use the default β€œpretty” preset for clean output.

import { trace, debug, info, warn, error, fatal } from "logry";

info("πŸ‘‹πŸΌ Hi there!");

// second argument is metadata (meta)
warn("Who are you?", { name: "Logry" });

// you can also pass an Error
error("Uh-oh!", new Error("Lost in the code"));

Sparkles Creating a Custom Logger Instance​

Call logry() to create a logger.
The default level is warn, so only warn, error, and fatal logs are shown.

import { logry } from "logry";

// Create a custom logger instance (defaults to id: 'default' and level: 'warn')
const logger = logry();

// ❌ This won't be shown, 'info' is lower than the default 'warn' level
logger.info("User logged in");

// βœ… This will be shown
logger.warn("User login warning");

A quick and easy setup to start logging right away:

import { logry } from "logry";

const logger = logry({
id: "MyLogger",
level: "debug", // Will show: debug, info, warn, error, fatal (trace will be hidden)
});
✨ Want a more customized setup?

A fully customizable logger setup when you need more control and personality:

import { logry } from "logry";

const logger = logry({
id: "🌐 My Logger",
level: "info",
scope: ["auth", "api"],
context: { env: "production", appVersion: "2.5.1" },
preset: "verbose", // "pretty" | "pretty-expanded" | "minimal" | "verbose"
normalizerConfig: {
node: {
timestamp: { style: "iso" },
// ...
},
browser: {
timestamp: { style: "pretty" },
// ...
},
},
formatterConfig: {
node: {
id: { ansiStyle: "\x1b[35m" },
message: {
customFormatter: ({ fieldValue }) => ({
fieldValue: "\n" + fieldValue.toUpperCase(),
}),
},
// ...
},
browser: {
id: { cssStyle: "color: purple;" },
context: { format: "compact" },
// ...
},
},
handlerManagerConfig: {
// ...
},
});

Joystick Connect with the Outside World​

Want to send your logs to files, Slack, or other services?
Check out the ✨ Handlers & Integrations to see how Logry integrates with real-world outputs.