Logging: Improve threadsafety (JuliaLang#57591) (#229)
Closes JuliaLang#57376
Closes JuliaLang#34037
- Adds a lock in `SimpleLogger` and `ConsoleLogger` for use on maxlog
tracking and stream writes to improve threadsafety.
Closely similar to JuliaLang#54497
- Turns the internal `_min_enabled_level` into a `Threads.Atomic`. There
are [some direct
interactions](https://juliahub.com/ui/Search?type=code&q=_min_enabled_level&w=true)
to this internal in the ecosystem, but they should still work
```
julia> Base.CoreLogging._min_enabled_level[] = Logging.Info+1
LogLevel(1)
```
- Brings tests over from JuliaLang#57448
Performance seems highly similar:
```
julia> @time for i in 1:10000
@info "foo" maxlog=10000000
end
[ Info: foo
...
0.481446 seconds (1.33 M allocations: 89.226 MiB, 0.49% gc time)
```
```
0.477235 seconds (1.31 M allocations: 79.002 MiB, 1.77% gc time)
```
Co-authored-by: Tomáš Drvoštěp <tomas.drvostep@gmail.com>