fix memory leak for function _safe_log

In _safe_log it uses recursive closure. The gc can not free stack for
this recursive closure for cycle-reference. So cut down the cycle
to fix it.

Resolved-bug: #1365892
Change-Id: I05fbd7091b886344d76b172a5ad66d9225599d69
Merge "fix memory leak for function _safe_log"