Re: BUG #13594: pg_ctl.exe redirects stderr to Windows Events Log if stderr is redirected to pipe - Mailing list pgsql-bugs
From | Michael Paquier |
---|---|
Subject | Re: BUG #13594: pg_ctl.exe redirects stderr to Windows Events Log if stderr is redirected to pipe |
Date | |
Msg-id | CAB7nPqQ+CybqD8-MemC0qQrUwC3eCOTGqpmTSKfSvBm6GdBsjg@mail.gmail.com Whole thread Raw |
In response to | Re: BUG #13594: pg_ctl.exe redirects stderr to Windows Events Log if stderr is redirected to pipe (Egon Kocjan <ekocjan@gmail.com>) |
Responses |
Re: BUG #13594: pg_ctl.exe redirects stderr to Windows Events
Log if stderr is redirected to pipe
Re: BUG #13594: pg_ctl.exe redirects stderr to Windows Events Log if stderr is redirected to pipe |
List | pgsql-bugs |
On Mon, Aug 31, 2015 at 11:56 PM, Egon Kocjan wrote: > On 31.8.2015 8:51, Michael Paquier wrote: >> Egon, would the patch attached help in your case? >> > > diff -ur postgresql-9.6devel.orig\src\bin\pg_ctl\pg_ctl.c > postgresql-9.6devel\src\bin\pg_ctl\pg_ctl.c > --- postgresql-9.6devel.orig\src\bin\pg_ctl\pg_ctl.c Mon Aug 31 13:16:51 > 2015 > +++ postgresql-9.6devel\src\bin\pg_ctl\pg_ctl.c Mon Aug 31 15:12:54 2015 > @@ -215,7 +215,7 @@ > * On Win32, we print to stderr if running on a console, or write to > * eventlog if running as a service > */ > - if (!pgwin32_is_service()) /* Running as a service */ > + if (pgwin32_is_service()) /* Running as a service */ > { > char errbuf[2048]; /* Arbitrary size? */ This one is obviously a stupid mistake of my patch :) > @@ -2131,6 +2131,9 @@ > progname = get_progname(argv[0]); > set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_ctl")); > start_time = time(NULL); > + > + write_stderr("%s: test test\n", > + progname); > > /* > * save argv[0] so do_start() can look for the postmaster if necessary. > we > > > 1) It now works ok for development under regular account. Thanks for the additional tests, that's still a win so this patch is a good thing. Relying on isatty is definitely something that we should treat as a bug here and backpatch. On master and REL9_5_STABLE, what I sent previously, with the call of pgwin32_is_service fixed in pg_ctl.c is fine. For back branches, we could simply copy pgwin32_is_service in pg_ctl.c and rely on that. It seems like the safer approach. Thoughts from other hackers on the matter? > 2) However there is no output on stderr when pg_ctl is running as a > subprocess of a service. So I would still have to patch pg_ctl if I want > stderr. I haven't looked into elog.c yet, maybe stderr from there would be > good to have as well? So far, pg_ctl output and pg_logs\* was enough for me > to debug the installations. Technically, I could also monitor Windows event > log and dump events on the fly into my report file. But it seems simpler to > just patch PostgreSQL locally to force stderr and reuse all the logic from > the Unix port... I wished we had such a switch a couple of times and I have as well some code paths that would benefit a redirection of those logs to stderr instead of the event log. Still this sounds like a new feature to me. Hence, what about for example adding a Windows-only option that can be used to enforce where logs are redirected, let's say --log-output with the following values: - default, which is what we have now - stderr, to enforce the output to stderr - eventlog, to enforce redirection to the event logs. Would you like to work on this patch? Regards, -- Michael
pgsql-bugs by date: