Logging lock acquire, release and failure

By taking an optional log argument in BasicLock. It logs time taken in each log, i.e. time taken to acquire lock, time the lock was held and time taken if lock was not acquired.