I would like to do the equivalent of c or php fopen() and fwrite(). I am not trying to dump a table to disk. I am trying to do some debug logging during development.
You can RAISE NOTICE or DEBUG messages in a plpgsql function or a DO statement which are written to the DB log file.
NOTICE
DEBUG