Re: print in plpython not appearing in logs

From: Ludwig Isaac Lim <ludz_lim(at)yahoo(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: print in plpython not appearing in logs
Date: 2022-12-05 02:42:20
Message-ID: 893661785.901171.1670208140915@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Tom:

>> I'm having problems wherein my print() statements inside my plpython stored proc are not appearing in postgresql log. I tried setting the file=sys.stderr

> Hmm.  I can tell you that with "logging_collector = on", I would only expect the logs to capture stderr output, not stdout.  So it makes
> sense to me that plain "print" would disappear into the bit bucket. But if you specify stderr output, it ought to work.  I don't know
> enough Python to know why it's not working, but it seems to me this is primarily a Python question not a Postgres question.  Maybe you need
> an explicit fflush-equivalent step?  Dunno.

>            regards, tom lane

As usual, thank you for pointing out where problem lies.

I made it work by adding flush=True flag to the print() statement.

print("oink oink", file=sys.stderr, flush=True)

I was under the wrong impression that output to stderr are automatically flushed.

Thank you once again.

Regards,
Ludwig

In response to

Browse pgsql-general by date

  From Date Subject
Next Message shashidhar Reddy 2022-12-05 05:49:00 Re: plpgsql_check_function issue after upgrade
Previous Message Michael Paquier 2022-12-05 01:14:52 Re: Libpq linked to LibreSSL