-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
print access log according to the attachment settings #988
Conversation
@@ -157,6 +158,9 @@ public class MotanConstants { | |||
public static final String TRACE_CRECEIVE = "TRACE_CRECEIVE";// client端接收response | |||
public static final String TRACE_CDECODE = "TRACE_CDECODE"; // client端解码response | |||
|
|||
// ------------------ attachment constants ----------------- | |||
public static final String ATT_PRINT_TRACE_LOG = "print_trace_log"; // 针对单请求是否打印(access)日志 |
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.
控制的是access log,使用trace字眼是否合适呢?
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.
trace log是一个纵向行为,trace log 标记可以控制整个链路中不同位置的log 行为,不只是针对access 日志,后续其他地方也可能会处理该标记,包括业务侧。
} | ||
|
||
@Override | ||
public Response filter(Caller<?> caller, Request request) { | ||
if (accessLog == null) { | ||
accessLog = caller.getUrl().getBooleanParameter(URLParamType.accessLog.getName(), URLParamType.accessLog.getBooleanValue()); | ||
} | ||
if (accessLog || MotanSwitcherUtil.isOpen(ACCESS_LOG_SWITCHER_NAME)) { | ||
if (accessLog || needLog(request)) { |
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.
这里判断有点别扭,应该只一个方法needLog去判断,是否需要打印逻辑封装在needLog里面。
如果按着目前判断思路,if (accessLog || 特例情况1 || 特例情况2 || 特例情况2||...),特例多起来不易于理解和维护。
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.
这里的想法是把access自身配置显示独立出来,其他都属于非配置情况下打印accesslog的场景,后续其他判断条件都会在needlog方法中进行判断。这里可以对needlog方法增加注释来进行补充说明
584e8af
to
b6ab469
Compare
10cc239
to
c92a902
Compare
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
print access log according to the attachment settings