Complete logging functionality

Works on Hive 13 but has errors in Hive 14 due to schema changes!!