add logging and option to log to console