python: Unify trace and log

Unify the trace and log implementation across scripts, so that we may
find script problem in a better way.