← back to Small Business Builder
src/lib/log.js
13 lines
// Tiny structured logger — JSON-line w/ timestamp + level
function emit(level, msg, extra) {
const line = { ts: new Date().toISOString(), level, msg, ...(extra || {}) };
// eslint-disable-next-line no-console
console.log(JSON.stringify(line));
}
export const log = {
info: (m, x) => emit('info', m, x),
warn: (m, x) => emit('warn', m, x),
err: (m, x) => emit('error', m, x),
dbg: (m, x) => process.env.DEBUG ? emit('debug', m, x) : undefined,
};