Logging and exception treatment

Simple log class implemented, code reviewed and bug precautions taken