When using serial ports for logging, an infinite recursion occurs if the
serial port cannot be opened.
The solution is to add the serial port log handler only after the serial
port has been opened successfully.
Closes-bug: #1692888
Change-Id: Ifb2352292dd31869ee6d5ff83fe53584dd684ebd