Refactor how logging snippet generated.