-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.js
More file actions
30 lines (26 loc) · 734 Bytes
/
Copy pathlogger.js
File metadata and controls
30 lines (26 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// utils/logger.js
// Einfacher Logger, damit wir überall saubere Logs haben,
// ohne zusätzliche npm-Pakete (winston, pino, etc.)
function log(level, ...args) {
const timestamp = new Date().toISOString();
const tag = `[${timestamp}] [${level.toUpperCase()}]`;
switch (level) {
case "error":
console.error(tag, ...args);
break;
case "warn":
console.warn(tag, ...args);
break;
case "info":
console.info(tag, ...args);
break;
default:
console.log(tag, ...args);
}
}
module.exports = {
info: (...args) => log("info", ...args),
warn: (...args) => log("warn", ...args),
error: (...args) => log("error", ...args),
debug: (...args) => log("debug", ...args),
};