docs(logs): changes how logs are put into the db they will be there name vs key

This commit is contained in:
2025-03-20 14:07:37 -05:00
parent e833c48cc8
commit 18daca904e

View File

@@ -8,6 +8,15 @@ type Log = {
level: string;
msg: string;
};
const pinoLogLevels: any = {
10: "trace",
20: "debug",
30: "info",
40: "warn",
50: "error",
60: "fatal",
};
// Create a custom transport function
export default async function (log: Log) {
//const {username, service, level, msg, ...extra} = log;
@@ -15,8 +24,11 @@ export default async function (log: Log) {
return build(async function (source) {
for await (let obj of source) {
// Insert log entry into the PostgreSQL database using Drizzle ORM
// convert to the name to make it more easy to find later :P
const levelName = pinoLogLevels[obj.level] || "unknown";
await db.insert(logs).values({
level: obj.level,
level: levelName,
username: obj?.username.toLowerCase(),
service: obj?.service.toLowerCase(),
message: obj.msg,