Support better logging (Fixes --debug option)

Change-Id: Ib809f301f1e71ad2e8f7fab07c1b94601b8288bb