Logging lock acquire, release and failure

By taking an optional log argument in BasicLock.

Will be adding tests after someone looks at it.