Why are you using dynamic query and not just run insert normally? And even for dynamic query it shows basically a worst possible way to do it, that is prone to sql injection. Of course the problem is unlikely now given that the values come from pg itself, and have pretty well defined values, but why do it unsafely even in such simple case?!
RAISE NOTICE 'Recorded execution of command % with event %', tg_tag, tg_event;
END;
$$ LANGUAGE plpgsql;
CREATE EVENT TRIGGER log_ddl_info_start ON ddl_command_start EXECUTE PROCEDURE log_ddl_execution();
CREATE EVENT TRIGGER log_ddl_info_end ON ddl_command_end EXECUTE PROCEDURE log_ddl_execution();
Is there a way to log the object name (or the oid) in the function?