Refactor logging logic into new CLogger class