CREATE OR REPLACE FUNCTION notify_new_log()
RETURNS trigger AS $$
BEGIN
  PERFORM pg_notify('logs_channel', row_to_json(NEW)::text);
  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER logs_notify_trigger
AFTER INSERT ON logs
FOR EACH ROW
EXECUTE FUNCTION notify_new_log();