TypeScript logger with level filtering and context support.
// Source: https://github.com/Cesarjoquin/Marketing-Skills | License: MIT | Copyright 2025 Corey Haines
// Provided via justclaw.it.com; keep this notice with the code.
export type LogLevel = "debug" | "info" | "warn" | "error";
export interface LogContext {
[key: string]: unknown;
}
export interface Logger {
debug(message: string, context?: LogContext): void;
info(message: string, context?: LogContext): void;
warn(message: string, context?: LogContext): void;
error(message: string, context?: LogContext): void;
child(bindings: LogContext): Logger;
}
const LEVEL_ORDER: Record<LogLevel, number> = {
debug: 10,
info: 20,
warn: 30,
error: 40,
};
function formatContext(context?: LogContext): string {
if (!context || Object.keys(context).length === 0) {
return "";
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key