Skip to content

Add RWMutex to logger to prevent data races on concurrent access#17

Merged
doron-sincere merged 1 commit intomasterfrom
add-logger-mutex
Apr 3, 2026
Merged

Add RWMutex to logger to prevent data races on concurrent access#17
doron-sincere merged 1 commit intomasterfrom
add-logger-mutex

Conversation

@doron-sincere
Copy link
Copy Markdown
Member

Summary

  • Add sync.RWMutex to the logger struct to make concurrent access safe
  • Log methods (warn, error, info, etc.) take RLock for level checks and output
  • Set methods (SetLevel, SetOutput, SetTimestampFlags, SetStaticField, SetStackTrace) take exclusive Lock
  • Zero API changes — sync.RWMutex zero value is unlocked, so no constructor changes needed

- Protect level, flags, staticArgs, and output fields with sync.RWMutex
- Log methods take RLock for level checks and output
- Set methods take exclusive Lock
@doron-sincere doron-sincere requested a review from AObuchow April 3, 2026 00:40
@doron-sincere doron-sincere merged commit d179442 into master Apr 3, 2026
1 check passed
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