Skip to content
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

Merged
merged 5 commits into from
Feb 14, 2019
Merged

add global functions #2

merged 5 commits into from
Feb 14, 2019

Conversation

nolouch
Copy link
Member

@nolouch nolouch commented Jan 30, 2019

Signed-off-by: nolouch nolouch@gmail.com

Signed-off-by: nolouch <nolouch@gmail.com>
@nolouch nolouch requested review from zimulala and rleungx January 30, 2019 09:37
@nolouch nolouch changed the title add global function add global functions Jan 30, 2019
Copy link

@zimulala zimulala left a 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>
@nolouch
Copy link
Member Author

nolouch commented Jan 31, 2019

PTAL @zimulala

_globalS = _globalL.Sugar()
_globalMu sync.RWMutex
_globalL, _globalR = newStdLogger()
_globalS = _globalL.Sugar()
Copy link
Member

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?

Copy link
Member Author

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.

global.go Show resolved Hide resolved
@siddontang
Copy link
Member

Be remember that there is a problem when we use Mutex for GetLevel, see pingcap/tidb#7986

global.go Outdated Show resolved Hide resolved
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...)

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?

Copy link
Member Author

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.

Copy link

@zimulala zimulala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nolouch nolouch merged commit b37da76 into master Feb 14, 2019
@nolouch nolouch deleted the export branch February 14, 2019 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants