mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-20 22:03:48 +00:00
7bf0f71f86
Replace the history-driven lib/ + utils/ split with DDD layers: - domain/: aggregate, repositories, value objects, pure parsers/format - application/: feed-service, email-processor, feed-fetcher, stats - infrastructure/: logging, auth, KV/R2 adapters, HTTP, framework glue Pure file relocation; imports updated mechanically. Behaviour unchanged. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
27 lines
777 B
TypeScript
27 lines
777 B
TypeScript
type LogLevel = "info" | "warn" | "error" | "debug";
|
|
|
|
function log(
|
|
level: LogLevel,
|
|
message: string,
|
|
data?: Record<string, unknown>,
|
|
): void {
|
|
const entry = data ? { level, message, ...data } : { level, message };
|
|
const line = JSON.stringify(entry);
|
|
if (level === "error" || level === "warn") {
|
|
console.error(line);
|
|
} else {
|
|
console.log(line);
|
|
}
|
|
}
|
|
|
|
export const logger = {
|
|
info: (message: string, data?: Record<string, unknown>) =>
|
|
log("info", message, data),
|
|
warn: (message: string, data?: Record<string, unknown>) =>
|
|
log("warn", message, data),
|
|
error: (message: string, data?: Record<string, unknown>) =>
|
|
log("error", message, data),
|
|
debug: (message: string, data?: Record<string, unknown>) =>
|
|
log("debug", message, data),
|
|
};
|