TwP / logging

A flexible logging library for use in Ruby programs based on the design of Java's log4j library.
https://rubygems.org/gems/logging
MIT License
530 stars 101 forks source link

Fix Logging::Logger#level= to be thread-safe #201

Closed MikaelSmith closed 5 years ago

MikaelSmith commented 5 years ago

Creating a new logger while also updating the level of an existing logger can produce

can't add a new key into hash during iteration

because both operate on the same hash of loggers but use different mutexes. Update them to share the same mutex.

Fixes #200.

MikaelSmith commented 5 years ago

This appears to fix my reproduction case from #200.

TwP commented 5 years ago

This change makes perfect sense. I'm going to merge the fix and then tinker with the variable names a smidge - rename _reentrant_mutex to a simpler mutex.