Refactor logging in low level API