Logging
This commit is contained in:
18
src/log.js
Normal file
18
src/log.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// Schlanker, konsistenter Logger. Alle Ausgaben mit Zeitstempel + [fsvc]-Präfix,
|
||||
// damit man im Container-Log Fileservice-Zeilen sofort erkennt.
|
||||
// Im Test (NODE_ENV=test) still, damit die Jest-Ausgabe sauber bleibt.
|
||||
const silent = process.env.NODE_ENV === 'test';
|
||||
|
||||
const ts = () => new Date().toISOString();
|
||||
|
||||
function info(...args) {
|
||||
if (!silent) console.log(`${ts()} [fsvc]`, ...args);
|
||||
}
|
||||
function warn(...args) {
|
||||
if (!silent) console.warn(`${ts()} [fsvc] ⚠`, ...args);
|
||||
}
|
||||
function error(...args) {
|
||||
if (!silent) console.error(`${ts()} [fsvc] ✖`, ...args);
|
||||
}
|
||||
|
||||
module.exports = { info, warn, error };
|
||||
Reference in New Issue
Block a user