-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Refactor log #3446
Refactor log #3446
Conversation
~~how about #2521 ~~ |
pc, _, _, _ := runtime.Caller(2) | ||
details := runtime.FuncForPC(pc).Name() | ||
if len(details) >= trim { | ||
details = details[trim:] |
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.
how about trimming the string until the first .
too, so that (*Handler).Process
disappears? then it is a pure refactor.
I am in favor of removing errors.generated.go, the file seemed annoying to copy for me.
Is there a runtime penalty for checking the stack like this?
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.
We could trim more, but I think method name could be helpful as well. Many logger specifically does that.
For runtime cost, old way use reflect too. Cost should be similar. In general I would prefer save people time vs cpu time
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.
In general I would prefer save people time
get rid of config.pb.go please thank you
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.
Are you taking about whole use of Protobuf?
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.
yeah. I suppose it's for the users API? biggest trouble in writing the first version of the transport was to install the right version of protobuf compiler
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.
that's learning time, not wasted
A lot of people hate Protobuf, it's controversy around the original author of v2ray.
My take is it is better for backend API dev with built-in types and compatibility and encode efficiency. I think it is an interesting choice here, has both good and bad.
BTW my next priority going to improve on xray APIs..
Planned for 1.9 |
Given the likelihood of merge conflict with other work, I will merge to main later if no further comments.. |
感觉在小版本改日志格式不太好, |
那(如之前讨论)我可以加个字符串截取 这样就是纯 refactor? |
* Refactor log * Add new log methods * Fix logger test * Change all logging code * Clean up pathObj * Rebase to latest main * Remove invoking method name after the dot
This is just an example of the code. I'm trying to:
LogInfo(ctx context.Context, msg ...interface{})
new log:
[1350929471] proxy/freedom.(*Handler).Process: connection opened to tcp:127.0.0.1:46565, local endpoint 127.0.0.1:41428, remote endpoint 127.0.0.1:46565
old log:
[1350929471] proxy/freedom: connection opened to tcp:127.0.0.1:46565, local endpoint 127.0.0.1:41428, remote endpoint 127.0.0.1:46565