Added Logging classes

Borrowed the logging mechanism from my another project TouchBoard.
and a few cosmetic changes to the code while trying to understand it.