improved logging and panic handling.

Change-Id: I6809a7017a7a7bebdfed61134efb2a9df5783afe
Reviewed-on: http://review.couchbase.org/39072
Reviewed-by: Deepkaran Salooja <deepkaran.couchbase@gmail.com>
Reviewed-by: Pratap Chakravarthy <prataprc@couchbase.com>
Tested-by: Pratap Chakravarthy <prataprc@couchbase.com>