-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat: add func GetLevel() uint32 in package logx/logc #4595
Comments
You can just use Debug series of functions. |
I understand your suggestion to use In some scenarios, the preparation of log content can be computationally expensive, such as when serializing large objects to JSON or performing other complex operations. For example: logx.Debugf("Debug data: %s", expensiveComputation()) Even if the current log level is By introducing a if logx.GetLevel() == logx.DebugLevel {
data, _ := json.Marshal(largeObject)
logx.Debugf("Debug data: %s", data)
} This approach provides a significant performance improvement in cases where the preparation of log content is non-trivial. Additionally, many other logging libraries implement similar functionality for the same reason:
Adding |
Is your feature request related to a problem? Please describe.
User's business code don't know current log level, need a function to get it.
Describe the solution you'd like
Add function:
How to use
User can write debug log info when need it:
The text was updated successfully, but these errors were encountered: