upd: menerapkan log pada semua aksi

This commit is contained in:
2026-04-13 16:42:36 +08:00
parent 14a9e2c687
commit 2cf96135f9
8 changed files with 121 additions and 31 deletions

18
src/lib/logger.ts Normal file
View File

@@ -0,0 +1,18 @@
import { prisma } from './db'
import { LogType } from '../../generated/prisma'
export async function createSystemLog(userId: string, type: LogType, message: string) {
try {
return await prisma.log.create({
data: {
userId,
type,
message,
},
})
} catch (error) {
console.error('[Logger Error]', error)
// Don't throw, we don't want logging errors to break the main application flow
return null
}
}