Reorganize log method

Externalize each step of logging in a method