upd: menerapkan log pada semua aksi
This commit is contained in:
18
src/lib/logger.ts
Normal file
18
src/lib/logger.ts
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user