monkeytype/backend/utils/logger.ts
Bruce Berrios 3240abc22e
Enable strict null checks in backend (#2639)
* Enable strict null checks in backend

* Fix

* Use non-null assertion

* Add none
2022-03-07 11:10:07 -05:00

23 lines
460 B
TypeScript

import db from "../init/db";
interface Log {
timestamp: number;
uid: string;
event: string;
message: string;
}
export default {
async log(event: string, message: any, uid?: string): Promise<void> {
const logsCollection = db.collection<Log>("logs");
console.log(new Date(), "\t", event, "\t", uid, "\t", message);
logsCollection.insertOne({
timestamp: Date.now(),
uid: uid ?? "",
event,
message,
});
},
};