missionlog v3.0.2
missionlog
π missionlog is a lightweight, structured logging package designed for performance, flexibility, and ease of use. It works as a drop-in replacement for console.log or ts-log, and offers both log level filtering, optional tag filtering, and customizable output handlingβall in a tiny (~1KB) package.
β Fully Typed (TypeScript) β’ β ESM & CJS Support β’ β Zero Dependencies β’ β 100% Coverage
β¨ Why Use missionlog?
β
Drop-in Replacement for console.log & ts-log β Start using it instantly!
β
Seamless Upgrade to Tagged Logging β Reduce log clutter and focus on what's important.
β
Configurable Log Levels β Adjust visibility for log level and tags at runtime.
β
Customizable Output β Send logs anywhere: console, JSON, cloud services.
β
Blazing Fast Performance β O(1) log level lookups for minimal overhead.
β
TypeScript-First β Full type safety, no need for @types.
β
Works Everywhere β Browser, Node.js, Firebase, AWS Lambda etc.
π¦ Installing
npm i missionlog π― Focus on What Matters, When It Matters
missionlog can filter logs dynamically by level or tag to avoid clutter and help you focus on what's important.
π Example
import { DEFAULT_TAG, log, LogLevel, LogLevelStr, tag } from "missionlog";
import chalk from "chalk";
// Tags aren't required., This works just like console
log.error("Alert! Evil twin detected!");
// Use the built-in **"Dummy"** logger and becomes a no-op
log.info(tag.Engineering, "Engaging warp drive! Destination: The Final Frontier.");
// Assign tags levels, (TRACE < DEBUG < INFO < WARN < ERROR < OFF)
log.init({ Engineering: LogLevel.INFO, Transporter: LogLevel.DEBUG });
// Log with a tag
log.info(tag.Engineering, "Warp Factor 9!");
// Override the built-in **Dummy** logger with a custom behavior
log.init({ Engineering: LogLevel.INFO }, createLogHandler());
// Engineering's level is INFO+ so this gets logged!
log.info(tag.Engineering, "Warp Factor 5.");
// Gets filtered since Engineering is INFO+
log.debug(tag.Engineering, "Warp Factor 9!");
// Update tag levels and override default (INFO)
log.init({
Engineering: LogLevel.TRACE,
[DEFAULT_TAG]: LogLevel.ERROR, // used for logs without a tag
Transporter: LogLevel.DEBUG,
});
// Log an error
const error = new Error("Warp core breach!");
log.error(tag.Engineering, "π¨ Red Alert!", error.message);
// Show some color!
log.debug(tag.Transporter, "β¨ Beam me up, Scotty!");
// Log objects properly
log.warn(tag.Transporter, "Transporter anomaly detected,", { evilTwin: true });
// Replace dummy logger with custom behavior
function createLogHandler() {
const logConfig: Record<
LogLevelStr,
{ color: (text: string) => string; method: (...args: unknown[]) => void }
> = {
ERROR: { color: chalk.red, method: console.error },
WARN: { color: chalk.yellow, method: console.warn },
INFO: { color: chalk.green, method: console.log },
DEBUG: { color: chalk.magenta, method: console.log },
TRACE: { color: chalk.cyan, method: console.log },
OFF: { color: () => '', method: () => {} }, // No-op
};
return (level: LogLevelStr, tag: string, message: unknown, params: unknown[]) => {
const { method, color } = logConfig[level];
const logLine = `[${color(level)}] ${tag ? tag + ' - ' : ''}${message}`;
method(logLine, ...params);
};
}
π License
MIT License
Β© 2019-2025 Ray Martone
π Install missionlog today and make logging clean, structured, and powerful!
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
1 year ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago