Add events module with dashboard UI, scheduling, signups, and settings updates; extend env/readme.
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
type LogLevel = 'INFO' | 'WARN' | 'ERROR';
|
||||
type LogSink = (entry: { level: LogLevel; message: string; timestamp: number }) => void;
|
||||
|
||||
let sink: LogSink | null = null;
|
||||
|
||||
export const logger = {
|
||||
info: (msg: string) => console.log(`[INFO] ${msg}`),
|
||||
warn: (msg: string) => console.warn(`[WARN] ${msg}`),
|
||||
error: (msg: string, err?: unknown) => console.error(`[ERROR] ${msg}`, err)
|
||||
info: (msg: string) => {
|
||||
const entry = { level: 'INFO' as LogLevel, message: msg, timestamp: Date.now() };
|
||||
if (sink) sink(entry);
|
||||
console.log(`[INFO] ${msg}`);
|
||||
},
|
||||
warn: (msg: string) => {
|
||||
const entry = { level: 'WARN' as LogLevel, message: msg, timestamp: Date.now() };
|
||||
if (sink) sink(entry);
|
||||
console.warn(`[WARN] ${msg}`);
|
||||
},
|
||||
error: (msg: string, err?: unknown) => {
|
||||
const entry = { level: 'ERROR' as LogLevel, message: msg, timestamp: Date.now() };
|
||||
if (sink) sink(entry);
|
||||
console.error(`[ERROR] ${msg}`, err);
|
||||
},
|
||||
setSink: (fn: LogSink | null) => {
|
||||
sink = fn;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user