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
2459eafb
Commit
2459eafb
authored
Feb 13, 2026
by
yangjianbo
Browse files
feat: 完善日志
parent
3734abed
Changes
2
Hide whitespace changes
Inline
Side-by-side
backend/internal/service/openai_gateway_service.go
View file @
2459eafb
...
...
@@ -292,7 +292,7 @@ func logCodexCLIOnlyDetection(ctx context.Context, account *Account, apiKeyID in
}
log
:=
logger
.
FromContext
(
ctx
)
.
With
(
fields
...
)
if
result
.
Matched
{
log
.
Info
(
"OpenAI codex_cli_only
检测通过
"
)
log
.
Warn
(
"OpenAI codex_cli_only
允许官方客户端请求
"
)
return
}
log
.
Warn
(
"OpenAI codex_cli_only 拒绝非官方客户端请求"
)
...
...
backend/internal/service/openai_gateway_service_codex_cli_only_test.go
View file @
2459eafb
...
...
@@ -99,3 +99,23 @@ func TestLogCodexCLIOnlyDetection_NilSafety(t *testing.T) {
logCodexCLIOnlyDetection
(
context
.
Background
(),
nil
,
0
,
CodexClientRestrictionDetectionResult
{
Enabled
:
false
,
Matched
:
false
,
Reason
:
"disabled"
})
})
}
func
TestLogCodexCLIOnlyDetection_LogsBothMatchedAndRejected
(
t
*
testing
.
T
)
{
logSink
,
restore
:=
captureStructuredLog
(
t
)
defer
restore
()
account
:=
&
Account
{
ID
:
1001
}
logCodexCLIOnlyDetection
(
context
.
Background
(),
account
,
2002
,
CodexClientRestrictionDetectionResult
{
Enabled
:
true
,
Matched
:
true
,
Reason
:
CodexClientRestrictionReasonMatchedUA
,
})
logCodexCLIOnlyDetection
(
context
.
Background
(),
account
,
2002
,
CodexClientRestrictionDetectionResult
{
Enabled
:
true
,
Matched
:
false
,
Reason
:
CodexClientRestrictionReasonNotMatchedUA
,
})
require
.
True
(
t
,
logSink
.
ContainsMessage
(
"OpenAI codex_cli_only 允许官方客户端请求"
))
require
.
True
(
t
,
logSink
.
ContainsMessage
(
"OpenAI codex_cli_only 拒绝非官方客户端请求"
))
}
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