New command 'log' added

Code re-factoring, main.h added, 'log' command added