Refactor syslog logging into new function