-
Notifications
You must be signed in to change notification settings - Fork 30
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
add global functions #2
Conversation
Signed-off-by: nolouch <nolouch@gmail.com>
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.
Could we add two functions about setLevel and getLevel?
Signed-off-by: nolouch <nolouch@gmail.com>
PTAL @zimulala |
_globalS = _globalL.Sugar() | ||
_globalMu sync.RWMutex | ||
_globalL, _globalR = newStdLogger() | ||
_globalS = _globalL.Sugar() |
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.
When do we need to use sugar
?
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.
I'm not sure in our situation but keep supporting it.
Be remember that there is a problem when we use Mutex for GetLevel, see pingcap/tidb#7986 |
Signed-off-by: nolouch <nolouch@gmail.com>
// Debug logs a message at DebugLevel. The message includes any fields passed | ||
// at the log site, as well as any fields accumulated on the logger. | ||
func Debug(msg string, fields ...zap.Field) { | ||
L().WithOptions(zap.AddCallerSkip(1)).Debug(msg, fields...) |
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.
Could we add this option to the logger directly when creating the logger?
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.
Yes, we can. But I do not directly create the logger with this option because the user may use L()
,S()
without the export function.
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
Signed-off-by: nolouch nolouch@gmail.com