ancient start at porting table_log, todo: modernize+finish!