perf: logger (#186)

* feat: finish response

* perf: logger

* docs

* perf: log

* docs
This commit is contained in:
Archer
2023-08-17 23:19:19 +08:00
committed by GitHub
parent 324e4a0e75
commit 40168c56ea
26 changed files with 500 additions and 93 deletions

View File

@@ -65,6 +65,7 @@ export function withNextCors(handler: NextApiHandler): NextApiHandler {
};
}
/* start task */
export const startQueue = () => {
for (let i = 0; i < global.systemEnv.qaMaxProcess; i++) {
generateQA();
@@ -87,3 +88,13 @@ export const sseResponse = ({
event && res.write(`event: ${event}\n`);
res.write(`data: ${data}\n\n`);
};
/* add logger */
export const addLog = {
info: (msg: string, obj?: Record<string, any>) => {
global.logger.info(msg, { meta: obj });
},
error: (msg: string, obj?: Record<string, any>) => {
global.logger.error(msg, { meta: obj });
}
};