feat: add logging entity and types for structured log records

This commit is contained in:
Boris D
2025-10-06 16:41:56 +03:00
parent 67099969db
commit 6c95e9d5e0
3 changed files with 35 additions and 0 deletions

3
.gitignore vendored
View File

@ -22,6 +22,9 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
!src/query/logs
!src/query/logs/*
# Runtime data
pids
*.pid

View File

@ -0,0 +1,20 @@
import { Column, Entity, PrimaryGeneratedColumn } from "typeorm";
import { LogRecord } from "../logs.type";
@Entity("logs")
export class LogEntity {
@PrimaryGeneratedColumn("uuid")
id: string;
@Column({
type: "longtext",
nullable: false,
transformer: {
to: (value: any) => JSON.stringify(value),
from: (value: any) => JSON.parse(value),
},
})
record: LogRecord;
// TODO: projectId
}

View File

@ -0,0 +1,12 @@
export type LogLevel = "DEBUG" | "INFO" | "WARN" | "ERROR" | "FATAL";
export type LogLine = {
timestamp: string;
message: string;
level: LogLevel;
};
export type LogRecord = {
id: string;
lines: LogLine[];
};