Don't put logs in ~/.opam when used as a library

This initialises the root dir in /tmp until opam's cl options are parsed.

Closes  #1355
(also includes small fix to #1352)