feat: 修改打印逻辑 & 请求等待结果
All checks were successful
CI Monitor MIflow / build-image (push) Successful in 59s

This commit is contained in:
zhaoyingbo 2024-08-13 01:30:15 +00:00
parent 92fa30ef3d
commit b530229e90
6 changed files with 26 additions and 39 deletions

View File

@ -44,7 +44,7 @@ const summaryMr = async (
const { content: summarize } = await codeChatBot.invoke(summarizePrompt)
if (!summarize) throw new Error("Empty summarize")
// 记录总结日志
logger.debug(`summarize for Mr: ${summarize}`)
logger.info(`summarize for Mr: ${summarize}`)
return summarize as string
} catch {
// 记录错误日志

View File

@ -14,9 +14,9 @@ const PREFIX = "/gitlab_monitor"
const server = Bun.serve({
async fetch(req) {
// 添加请求ID
const logger = loggerIns.child({ requestId: uuid() })
try {
// 添加请求ID
const logger = loggerIns.child({ requestId: uuid() })
// 路由处理
const { exactCheck, fullCheck } = makeCheckPathTool(req.url, PREFIX)
// 非根路由打印
@ -29,7 +29,7 @@ const server = Bun.serve({
return netTool.ok("hello, there is gitlab monitor, glade to serve you!")
} catch (error: any) {
// 错误处理
console.error("🚀 ~ serve ~ error", error)
logger.error(`server error: ${error.message}`)
return netTool.serverError(error.message || "server error")
}
},

View File

@ -1,15 +0,0 @@
{
"keep": {
"days": true,
"amount": 14
},
"auditLog": "log/.477ef71694ce4c791e6f91cf40117d4a85785c6b-audit.json",
"files": [
{
"date": 1723259039565,
"name": "log/application-2024-08-10.log",
"hash": "fdd4f67d11fe79d1aedf242b8d2e1894fbd6a4679331098818c2324ec81678cd"
}
],
"hashType": "sha256"
}

View File

@ -4,21 +4,37 @@ import winston, { format } from "winston"
const isProd = process.env.NODE_ENV === "production"
const dailyRotateFileTransport = new winston.transports.DailyRotateFile({
filename: "./log/application-%DATE%.log",
const dailyRotateFileTransport4Info = new winston.transports.DailyRotateFile({
level: "info",
filename: "/home/work/log/egg-info-%DATE%.log",
datePattern: "YYYY-MM-DD",
zippedArchive: true,
maxSize: "20m",
maxFiles: "14d",
})
const transports: any[] = [new winston.transports.Console()]
const dailyRotateFileTransport4Debug = new winston.transports.DailyRotateFile({
level: "debug",
filename: "/home/work/log/egg-debug-%DATE%.log",
datePattern: "YYYY-MM-DD",
zippedArchive: true,
maxSize: "20m",
maxFiles: "14d",
})
const transports: any[] = [
new winston.transports.Console({
level: "info",
}),
]
if (isProd) {
transports.push(dailyRotateFileTransport)
transports.push(dailyRotateFileTransport4Info)
transports.push(dailyRotateFileTransport4Debug)
}
const loggerIns = winston.createLogger({
level: "info",
level: "silly",
format: format.combine(
format.colorize({
level: !isProd,

View File

@ -22,6 +22,7 @@ export const manageGitlabEventReq = async (
// 处理流水线钩子
if (eventType === "Pipeline Hook") {
const body = (await req.json()) as Gitlab.PipelineEvent
logger.debug(`body: ${JSON.stringify(body)}`)
const params = new URLSearchParams(req.url.split("?")[1])
return managePipelineEvent.manageRawEvent(body, apiKey, params)
}

View File

@ -1,15 +0,0 @@
{
"keep": {
"days": true,
"amount": 14
},
"auditLog": "log/.477ef71694ce4c791e6f91cf40117d4a85785c6b-audit.json",
"files": [
{
"date": 1723423178431,
"name": "log/application-2024-08-12.log",
"hash": "0bc427a58e73e382ac12bffa78e2d17ab09717e51a940fe5d71f786f5f1e6bcf"
}
],
"hashType": "sha256"
}