git-trunk/log: Refactor a bit and rename

Also introduce a global log lock that can be used to write larger log
messages atomically. The lock can be accessed using log.Lock() and
log.Unlock(). All the functions in the log package are locking the lock
automatically, unless the function names are prefixed with Unsafe.

Change-Id: 96223b9a77
Story-Id: 78913390