onexit: add an on exit callback utility

Adds a class that executes registered callbacks in its destructor. Since
static duration objects have their destructors called when returning
from main or calling exit then this can be used as a replacement for
on_exit.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
log: use on exit manager to flush logs on exit

on_exit is not portable, and atexit doesn't allow parameters to be
passed to callbacks.

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
on_exit: remove side effects from asserts

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Merge pull request #1044 from ceph/port/onexit

create on_exit replacement

Reviewed-by: Sage Weil <sage@inktank.com>