opscode/chef — pull request #655 by danielsdeleo (2013-02-25 05:12:31+00:00)
Title: [CHEF-3935] Replace stdlib Logger w/ a lock free variant

Subclasses Logger and its implementation classes to avoid using mutexes around log IO. This fixes error messages like this on ruby 2.0:

log writing failed. can't be called from trap context

On earlier Ruby versions, mutexes can be used in traps but there is a risk of deadlock.

----
There are other possible ways to fix the issue:
* Don't use the logger in traps. Everything else will work but we can't print messages when trapping a signal.
* Don't do *anything* in traps, write messages to a pipe and have a separate thread implement the trap logic.

The first method is okay, but probably needs some finesse to make the HUP and QUIT handlers work acceptably. The second option has some nice properties, but would involve quite a bit of work.

If we like the approach here of simplifying the logger, we might want to move the code to mixlib-log. Also, we should probably add functional tests for the trap handlers.