This is a complete rewrite of CCLogger