Skip to content

Commit

Permalink
feat: add log outgoing IP
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierJp committed Nov 6, 2024
1 parent 7fbea8c commit 437692b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/utils/network/interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export const logInterceptor = (response: AxiosResponse<any, any>) => {
//@ts-ignore
response?.cached,
startTime ? endTime - startTime : undefined,
(response?.config?.method || '').toUpperCase()
(response?.config?.method || '').toUpperCase(),
response?.request?.socket?.localAddress
)
);

Expand Down Expand Up @@ -70,7 +71,8 @@ export const errorInterceptor = (error: AxiosError) => {
status,
false,
startTime ? endTime - startTime : undefined,
error.request?.method
error.request?.method,
error?.request?.socket?.localAddress
)
);
}
Expand Down Expand Up @@ -112,7 +114,8 @@ export const formatLog = (
status: number,
isFromCached = false,
time = -1,
method: string
method: string,
outgoingIp: string
) => {
return `status=${status} time=${time} isFromCached=${isFromCached} request=${url} method=${method}`;
return `status=${status} time=${time} isFromCached=${isFromCached} request=${url} method=${method} out_ip=${outgoingIp}`;
};

0 comments on commit 437692b

Please sign in to comment.