basho/lager — pull request #97 by aleksandr-vin (2012-12-01 21:10:45+00:00)
Title: Add lager:dispatch_log/8 async mode

Add an option to choose **sync** or **async** mode of log event notification.

Each mode has its pros and cons:

**sync**:
* degrades caller process performance
* ensures all log events of one caller process to be handled completely by all lager backends
* guaranties the order of log events produced by one caller process to be handled by all lager backends in that order

**async**
* let the caller process continue its work not waiting for the lager backends at all
* does not guaranty complete log events handling by the end of the series of logging calls *(actually normal terminating of the lager should wait for its event manager message box exhaust)*
* does not guaranty complete log events handling at all *(event manager message box can be overwhelmed on high log load)*
* the order of the handling of log events is not guarantied too due a **no-message-order** guaranty in Erlang

Results of the **benchmark*** of the differences in this modes can be found [here](https://github.com/aleksandr-vin/lager_bench)

For more completeness of the solution I've added a flow control macros, they allow to build three versions of the `lager` module:
1. operating **strictly** in **sync** mode
2. operating **strictly** in **async** mode
3. operating in start-time configured (**dynamic**) mode (via app env `sync_dispatch_log`)