Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
d8563adc
Commit
d8563adc
authored
Apr 27, 2026
by
陈曦
Browse files
nfs写入加log
parent
065e4782
Pipeline
#82293
passed with stage
in 3 minutes and 21 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
backend/internal/service/request_capture_service.go
View file @
d8563adc
...
...
@@ -63,6 +63,11 @@ func NewRequestCaptureService(repo RequestCaptureLogRepository, cfg *config.Conf
if
cfg
!=
nil
{
nfsPath
=
cfg
.
RequestCapture
.
NFSPath
}
if
nfsPath
!=
""
{
logger
.
L
()
.
Info
(
"request_capture: NFS storage enabled"
,
zap
.
String
(
"nfs_path"
,
nfsPath
))
}
else
{
logger
.
L
()
.
Info
(
"request_capture: NFS storage disabled (nfs_path not configured), DB-only mode"
)
}
return
&
RequestCaptureService
{
repo
:
repo
,
nfsPath
:
nfsPath
,
...
...
@@ -86,6 +91,10 @@ func (s *RequestCaptureService) Capture(
nfsFilePath
=
s
.
buildNFSFilePath
(
apiKeyID
,
requestID
,
now
)
bodyCopy
:=
make
([]
byte
,
len
(
body
))
copy
(
bodyCopy
,
body
)
logger
.
L
()
.
Debug
(
"request_capture: launching nfs request write"
,
zap
.
Int64
(
"api_key_id"
,
apiKeyID
),
zap
.
String
(
"nfs_file"
,
nfsFilePath
),
)
go
s
.
writeToNFS
(
nfsFilePath
,
apiKeyID
,
userID
,
requestID
,
path
,
method
,
ipAddr
,
bodyCopy
,
now
)
}
...
...
@@ -141,6 +150,10 @@ func (s *RequestCaptureService) CaptureResponse(captureID int64, responseBody st
// NFS 响应文件:与请求文件同目录,文件名加 _response 后缀
if
nfsFilePath
!=
""
{
respPath
:=
nfsResponseFilePath
(
nfsFilePath
)
logger
.
L
()
.
Debug
(
"request_capture: launching nfs response write"
,
zap
.
Int64
(
"capture_id"
,
captureID
),
zap
.
String
(
"nfs_file"
,
respPath
),
)
s
.
writeResponseToNFS
(
respPath
,
captureID
,
responseBody
)
}
}()
...
...
@@ -202,6 +215,8 @@ func (s *RequestCaptureService) writeToNFS(
zap
.
String
(
"file"
,
filePath
),
zap
.
Error
(
err
),
)
}
else
{
logger
.
L
()
.
Debug
(
"request_capture: nfs request file written"
,
zap
.
String
(
"file"
,
filePath
))
}
}
...
...
@@ -254,5 +269,7 @@ func (s *RequestCaptureService) writeResponseToNFS(filePath string, captureID in
zap
.
String
(
"file"
,
filePath
),
zap
.
Error
(
err
),
)
}
else
{
logger
.
L
()
.
Debug
(
"request_capture: nfs response file written"
,
zap
.
String
(
"file"
,
filePath
))
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment