Declare the logger contract in the library instead of depending on @larvit/log

This commit is contained in:
2026-08-27 13:42:58 +02:00
parent ff3667e120
commit 8d245c82c4
18 changed files with 110 additions and 50 deletions
+20 -3
View File
@@ -1,5 +1,22 @@
import type { LogInt } from '@larvit/log';
import { Log } from '@larvit/log';
export type LogMetadata = Record<string, boolean | number | string>;
export type LogMethod = (msg: string, metadata?: LogMetadata) => void;
/** What the library needs from a logger. A `@larvit/log` instance satisfies it as it stands. */
export type SmppLog = {
debug: LogMethod;
error: LogMethod;
info: LogMethod;
verbose: LogMethod;
warn: LogMethod;
};
const noop: LogMethod = () => undefined;
/** The default: a library that says nothing unless the application asks it to. */
export const silentLog: LogInt = new Log({ logLevel: 'none' });
export const silentLog: SmppLog = {
debug: noop,
error: noop,
info: noop,
verbose: noop,
warn: noop,
};