Skip to content

[Feature] log Helper sprint, sprintf is executed before Filter Level, the performance consumption is very high #3209

@sendya

Description

@sendya

Please see the FAQ in our main README.md before submitting your issue.

What problem is the feature used to solve?

image
I try adding such a demo implementation, the CPU usage dropped to no more than 1%
func (h *Helper) CheckLevel(level Level) bool {
	l, ok := h.logger.(*Filter)
	return ok && level < l.level
}

// Debugf logs a message at debug level.
func (h *Helper) Debugf(format string, a ...interface{}) {
	if CheckLevel(LevelDebug) {
		return
	}
	_ = h.logger.Log(LevelDebug, h.msgKey, h.sprintf(format, a...))
}
image

Requirements description of the feature

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions