feat: add logging entity and types for structured log records
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@ -22,6 +22,9 @@ npm-debug.log*
|
|||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
|
|
||||||
|
!src/query/logs
|
||||||
|
!src/query/logs/*
|
||||||
|
|
||||||
# Runtime data
|
# Runtime data
|
||||||
pids
|
pids
|
||||||
*.pid
|
*.pid
|
||||||
|
|||||||
20
src/query/logs/entities/log.entity.ts
Normal file
20
src/query/logs/entities/log.entity.ts
Normal 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
|
||||||
|
}
|
||||||
12
src/query/logs/logs.type.ts
Normal file
12
src/query/logs/logs.type.ts
Normal 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[];
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user