Fix and improve threading behavior in Grumble.
Review Request #13016 — Created May 5, 2023 and submitted
We now conditionally and safely pull log and emoji index state from the
thread-local storage when needed, initializing it if missing. This is a
change from the previous method where we initialized on module load,
which wasn't sufficient.
The log information now shows details for threads.
GRUMBLE_MERGE_THREADS=1environment variable can now be set to
merge all logs together, instead of having per-thread logs.
There's also a fix for the log filename that ensures we use a base name
and not a full file path in all cases.
Tested these when debugging something with threads and process names
containing full file paths.