Upstream commit "Add liblog"

Adapted from upstream commit ecba7488c5cceaacef95836b1b476433451e7761.