Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppressing pjsua output in Python script

Tags:

python

curses

I'm writing a script that uses curses to produce a main window and a log window at the bottom of the screen.

It seems that when I import pjsua it insists on printing to the screen even though I have set log level to 0. Here's what it outputs:

15:49:09.716 os_core_unix.c !pjlib 2.0.1 for POSIX initialized
15:49:09.844 sip_endpoint.c  .Creating endpoint instance...
15:49:09.844          pjlib  .select() I/O Queue created (0x7f84690decd8)
15:49:09.844 sip_endpoint.c  .Module "mod-msg-print" registered
15:49:09.844 sip_transport.  .Transport manager created.
15:49:09.845   pjsua_core.c  .PJSUA state changed: NULL --> CREATED
15:49:09.896  pjsua_media.c  ..NAT type detection failed: Invalid STUN server or server not configured (PJNATH_ESTUNINSERVER)

Note it doesn't send this through the logging callback, meaning I have no way to put it in the log window with the rest of my logging information. Can anyone give me some advice on dealing with this output please?

Thanks

like image 387
Blark Avatar asked Sep 12 '26 21:09

Blark


1 Answers

If you can detect which stream it writes to, e.g. sys.stderr, you could redirect it somewhere by simple assignment of sys.stderr to another open file (or even /dev/null ?).

like image 72
mrkafk Avatar answered Sep 15 '26 11:09

mrkafk