-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
modify log-format, then every plugin log is associated with access log #1454
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1454 +/- ##
==========================================
+ Coverage 35.91% 43.52% +7.61%
==========================================
Files 69 76 +7
Lines 11576 12320 +744
==========================================
+ Hits 4157 5362 +1205
+ Misses 7104 6622 -482
- Partials 315 336 +21 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -36,7 +36,8 @@ type Log struct { | |||
} | |||
|
|||
func (l Log) log(level LogLevel, msg string) { | |||
msg = fmt.Sprintf("[%s] %s", l.pluginName, msg) | |||
requestID, _ := proxywasm.GetProperty([]string{"x_request_id"}) | |||
msg = fmt.Sprintf("[%s] [%s] %s", l.pluginName, string(requestID), msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
还有如果用户走下面 57 行的 logFormat
函数输出日志,还是不会输出 request ID 的。。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logFormat函数改了下,然后如果request_id获取失败的话,输出个nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
修改log wrapper记录日志时的format,使得每条插件的日志能够与网关访问日志关联起来,便于排查问题