Add log weight function.