Refactor action logging to reduce redundant code