Improve logging code.

- Write to log buffer ourselves instead of calling log, so the printed
  pid is correct
- Reduce debug spam

Change-Id: I9afe7249fc589268ea61419a7cfc724897981e9e
Merge branch 'cm-11.0' into martincz