refact log method