I have instructed PostgreSQL to csvlog its errors/notices. Then my script reads these files and put them back into a database table, then deletes the log file. This part is all working and stable.
My issue is that I never know which script is associated with an error/notice. As I have very much established by now, there is no such built-in option.
However, it strikes me that maybe I can send a custom string/text to the PostgreSQL session so that the csvlog includes this field when it makes its CSV log? If so, I could set this “session variable” to the path for my script client-side, and then have PG log the field without itself knowing which script was responsible for the error/notice?
Is this possible? If so, how?
(I already do logging client-side, but that’s just for the actual SQL queries, for statistics purposes. That log doesn’t include any errors/notices; the ones which are logged with the csvlog. I have no idea how I would detect these client-side, if it’s even possible. Everything is very cryptic and difficult in this environment.)