perf: code

This commit is contained in:
archer
2023-09-01 11:47:06 +08:00
parent 68cdf50cb6
commit 23cc2f81e9
8 changed files with 61 additions and 68 deletions

View File

@@ -94,7 +94,24 @@ 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 });
error: (msg: string, error?: any) => {
global.logger?.error(msg, {
meta: {
stack: error?.stack,
...(error?.config && {
config: {
headers: error.config.headers,
url: error.config.url,
data: error.config.data
}
}),
...(error?.response && {
response: {
status: error.response.status,
statusText: error.response.statusText
}
})
}
});
}
};