Add conditional logic for logger when it is not defined