feat: implement logging enhancements; add projectId and queryId to log entity; update query and logger services for improved logging; refactor query execution to support call stack tracking

This commit is contained in:
lborv
2025-10-11 19:36:43 +03:00
parent 08a62fa2c5
commit 967c89108a
14 changed files with 226 additions and 46 deletions

View File

@ -5,9 +5,11 @@ export abstract class Plugin {
protected log: TLog;
protected cookies: Record<string, string>;
protected headers: Record<string, string>;
protected callStack: number;
constructor(name: string, protected methods: string[] = []) {
this.name = name;
this.callStack = 0;
}
getName(): string {
@ -26,6 +28,10 @@ export abstract class Plugin {
this.headers = headers;
}
setCallStack(callStack: number) {
this.callStack = callStack;
}
setCookies(cookies: Record<string, string>) {
this.cookies = cookies;
}

View File

@ -33,6 +33,7 @@ export class QueryPlugin extends Plugin {
return await this.QueryExecuterService.runQuery(
id,
data,
this.callStack + 1,
this.headers,
this.cookies,
this.log

View File

@ -19,18 +19,28 @@ export class Vm {
private log: TLog;
private headers?: Record<string, string>;
private cookies?: Record<string, string>;
private callStack = 0;
constructor(
configs: {
memoryLimit: number;
timeLimit?: bigint;
cpuTimeLimit?: bigint;
modules: VModule[];
plugins: Plugin[];
functions: string[];
log: TLog;
headers?: Record<string, string>;
cookies?: Record<string, string>;
},
callStack = 0
) {
this.callStack = callStack;
if (this.callStack > 5) {
throw new Error("Maximum call stack size exceeded");
}
constructor(configs: {
memoryLimit: number;
timeLimit?: bigint;
cpuTimeLimit?: bigint;
modules: VModule[];
plugins: Plugin[];
functions: string[];
log: TLog;
headers?: Record<string, string>;
cookies?: Record<string, string>;
}) {
this.memoryLimit = configs.memoryLimit;
this.modules = configs.modules;
this.plugins = configs.plugins;
@ -71,6 +81,7 @@ export class Vm {
plugin.setLog(this.log);
plugin.setHeaders(this.headers);
plugin.setCookies(this.cookies);
plugin.setCallStack(this.callStack);
const result = await plugin[method](...args);
if (result && result.log) {