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

logger: don't call Getpid() inside the Format function #5632

Merged
merged 1 commit into from
Feb 8, 2025

Conversation

SandyXSD
Copy link
Contributor

@SandyXSD SandyXSD commented Feb 8, 2025

Format is called with the logger mutex locked.

func (entry *Entry) write() {
	entry.Logger.mu.Lock()
	defer entry.Logger.mu.Unlock()
	serialized, err := entry.Logger.Formatter.Format(entry)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
		return
	}
	if _, err := entry.Logger.Out.Write(serialized); err != nil {
		fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
	}
}

@jiefenghuang jiefenghuang merged commit 58cf613 into main Feb 8, 2025
35 checks passed
@jiefenghuang jiefenghuang deleted the fix-logger branch February 8, 2025 09:21
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.

2 participants