Code for Logging.

Copy-pasted some logging macros that needs some fix.
This commit introduce ugly code.