Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Confusion on logrus.Entry Level Field Behavior #1451

Open
SHawnHardy opened this issue Dec 7, 2024 · 1 comment
Open

Confusion on logrus.Entry Level Field Behavior #1451

SHawnHardy opened this issue Dec 7, 2024 · 1 comment
Labels

Comments

@SHawnHardy
Copy link

Hi, I am facing some confusion regarding the behavior of the Level field in the logrus.Entry struct.
Based on the documentation and examples, it seems that the Level field of an Entry is expected to represent the log level of the current log entry.

If I set the log level globally on a logrus.Logger instance, the Entry does not automatically inherit this level. Furthermore, when logging, logrus.Entry actually relies on the logrus.Logger's level to determine whether the log should be written. Does the Level field in logrus.Entry serve any other purpose, and should it be designed to stay synchronized with the logrus.Logger's level?

entry.go:

func NewEntry(logger *Logger) *Entry {
	return &Entry{
		Logger: logger,
		// Default is three fields, plus one optional.  Give a little extra room.
		Data: make(Fields, 6),
	}
}

func (entry *Entry) Log(level Level, args ...interface{}) {
	if entry.Logger.IsLevelEnabled(level) {
		entry.log(level, fmt.Sprint(args...))
	}
}
Copy link

github-actions bot commented Jan 7, 2025

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Jan 7, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant