Oh, and the way it isn't thread-safe is that it changes the global logging for the module.  If two threads run through this code at once, they'll both add handlers, which is fine, but then as the code is executing, both handlers will get the lines from both threads.