pjlib logging api issues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am testing the logging api in pjlib 2.4.5 with the attached test program.

The program is simple, it just sets a log callback and decoration without
the time.

This program shows some problems in pjlib:

1. Log messages are prefixed by a spurious space.
For example, a call to PJ_LOG(3, (__FILE__, "pj_log message 1")) shows:
log callback: --> INFO: pj_log message 1<--
                 ^
                 |
this: -----------+

It is inserted in pjlib/src/pj/log.c line 414:
    if (log_decor != 0 && log_decor != PJ_LOG_HAS_NEWLINE)
        *pre++ = ' ';

2. pjsua_init() Loses the logging configuration.
After calling pjsua_init the logging configuration is lost.
This is because of a call to pjsua_reconfigure_logging() in
pjsip/src/pjsua-lib/pjsua_core.c line 890:
    /* Initialize logging first so that info/errors can be captured */
    if (log_cfg) {
        status = pjsua_reconfigure_logging(log_cfg);
        if (status != PJ_SUCCESS)
            goto on_error;
    }

As a workaround, you can configure logging again after pjsua_init, but
there is no way to control the messages produced by pjsua_init itself.
See the difference in my test program with and without this workaround:

Output without workaround:
-> calling pjsua_logging_config_default()
-> calling pj_log_set_log_func()
-> calling pj_log_set_decor()
-> calling pj_log_set_level()
log callback: --> INFO: pj_log message 1<--
-> calling pjsua_create()
log callback: -->DEBUG: pjlib 2.4.5 for POSIX initialized<--
log callback: -->DEBUG: .select() I/O Queue created (0x62b9a0)<--
log callback: -->DEBUG: .Module "mod-msg-print" registered<--
log callback: -->DEBUG: .PJSUA state changed: NULL --> CREATED<--
-> calling pjsua_config_default()
-> calling pjsua_media_config_default()
-> calling pjsua_init()
18:43:33.065 sip_endpoint.c !.Module "mod-pjsua-log" registered
18:43:33.065 sip_endpoint.c  .Module "mod-tsx-layer" registered
18:43:33.065 sip_endpoint.c  .Module "mod-stateful-util" registered
18:43:33.065 sip_endpoint.c  .Module "mod-ua" registered
18:43:33.065 sip_endpoint.c  .Module "mod-100rel" registered
18:43:33.065 sip_endpoint.c  .Module "mod-pjsua" registered
18:43:33.065 sip_endpoint.c  .Module "mod-invite" registered
18:43:33.152       pa_dev.c  ..PortAudio sound library initialized, status=0
18:43:33.152       pa_dev.c  ..PortAudio host api count=2
18:43:33.152       pa_dev.c  ..Sound device count=8
18:43:33.152          pjlib  ..select() I/O Queue created (0x69cc38)
18:43:33.168    pjsua_vid.c  ..Initializing video subsystem..
18:43:33.229     v4l2_dev.c  ...Video4Linux2 has 1 devices
18:43:33.507      sdl_dev.c  ...SDL 2.0 initialized
18:43:33.507 colorbar_dev.c  ...Colorbar video src initialized with 2
device(s):
18:43:33.507 colorbar_dev.c  ... 0: Colorbar generator
18:43:33.507 colorbar_dev.c  ... 1: Colorbar-active
18:43:33.507 sip_endpoint.c  .Module "mod-evsub" registered
18:43:33.507 sip_endpoint.c  .Module "mod-presence" registered
18:43:33.507 sip_endpoint.c  .Module "mod-mwi" registered
18:43:33.507 sip_endpoint.c  .Module "mod-refer" registered
18:43:33.507 sip_endpoint.c  .Module "mod-pjsua-pres" registered
18:43:33.507 sip_endpoint.c  .Module "mod-pjsua-im" registered
18:43:33.507 sip_endpoint.c  .Module "mod-pjsua-options" registered
18:43:33.507   pjsua_core.c  .1 SIP worker threads created
18:43:33.507   pjsua_core.c  .pjsua version 2.4.5 for
Linux-3.16.6/x86_64/glibc-2.19 initialized
18:43:33.507   pjsua_core.c  .PJSUA state changed: CREATED --> INIT
18:43:33.507      logtest.c  pj_log message 2
18:43:33.507      logtest.c  pj_log message 3
-> calling pjsua_start()
18:43:33.507   pjsua_core.c  PJSUA state changed: INIT --> STARTING
18:43:33.507 sip_endpoint.c  .Module "mod-unsolicited-mwi" registered
18:43:33.507   pjsua_core.c  .PJSUA state changed: STARTING --> RUNNING
18:43:33.507      logtest.c  pj_log message 4
-> calling pjsua_destroy()
18:43:33.507   pjsua_core.c  Shutting down, flags=0...
18:43:33.507   pjsua_core.c  PJSUA state changed: RUNNING --> CLOSING
18:43:33.518   pjsua_call.c  .Hangup all calls..
18:43:33.518  pjsua_media.c  .Call 0: deinitializing media..
18:43:33.518  pjsua_media.c  .Call 1: deinitializing media..
18:43:33.518  pjsua_media.c  .Call 2: deinitializing media..
18:43:33.518  pjsua_media.c  .Call 3: deinitializing media..
18:43:33.518   pjsua_pres.c  .Shutting down presence..
18:43:34.518   pjsua_core.c  .Destroying...
18:43:34.518  pjsua_media.c  .Shutting down media..
18:43:34.653    pjsua_vid.c  ..Destroying video subsystem..
18:43:34.653    pjsua_vid.c  ...Window 0: destroying..
18:43:34.653    pjsua_vid.c  ...Window 1: destroying..
18:43:34.653    pjsua_vid.c  ...Window 2: destroying..
18:43:34.653    pjsua_vid.c  ...Window 3: destroying..
18:43:34.653    pjsua_vid.c  ...Window 4: destroying..
18:43:34.653    pjsua_vid.c  ...Window 5: destroying..
18:43:34.653    pjsua_vid.c  ...Window 6: destroying..
18:43:34.653    pjsua_vid.c  ...Window 7: destroying..
18:43:34.653    pjsua_vid.c  ...Window 8: destroying..
18:43:34.653    pjsua_vid.c  ...Window 9: destroying..
18:43:34.653    pjsua_vid.c  ...Window 10: destroying..
18:43:34.653    pjsua_vid.c  ...Window 11: destroying..
18:43:34.653    pjsua_vid.c  ...Window 12: destroying..
18:43:34.653    pjsua_vid.c  ...Window 13: destroying..
18:43:34.653    pjsua_vid.c  ...Window 14: destroying..
18:43:34.653    pjsua_vid.c  ...Window 15: destroying..
18:43:34.658       pa_dev.c  ..PortAudio sound library shutting down..
18:43:34.659 sip_transactio  .Stopping transaction layer module
18:43:34.659 sip_transactio  .Stopped transaction layer module
18:43:34.659 sip_endpoint.c  .Module "mod-unsolicited-mwi" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-pjsua-options" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-pjsua-im" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-pjsua-pres" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-pjsua" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-stateful-util" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-refer" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-mwi" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-presence" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-evsub" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-invite" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-100rel" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-ua" unregistered
18:43:34.659 sip_transactio  .Transaction layer module destroyed
18:43:34.659 sip_endpoint.c  .Module "mod-tsx-layer" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-msg-print" unregistered
18:43:34.659 sip_endpoint.c  .Module "mod-pjsua-log" unregistered
18:43:34.660 sip_endpoint.c  .Endpoint 0x620c38 destroyed
18:43:34.660   pjsua_core.c  .PJSUA state changed: CLOSING --> NULL
18:43:34.660   pjsua_core.c  .PJSUA destroyed...

Output with workaround:
-> calling pjsua_logging_config_default()
-> calling pj_log_set_log_func()
-> calling pj_log_set_decor()
-> calling pj_log_set_level()
log callback: --> INFO: pj_log message 1<--
-> calling pjsua_create()
log callback: -->DEBUG: pjlib 2.4.5 for POSIX initialized<--
log callback: -->DEBUG: .select() I/O Queue created (0x62b9a0)<--
log callback: -->DEBUG: .Module "mod-msg-print" registered<--
log callback: -->DEBUG: .PJSUA state changed: NULL --> CREATED<--
-> calling pjsua_config_default()
-> calling pjsua_media_config_default()
-> calling pjsua_init()
18:43:21.731 sip_endpoint.c !.Module "mod-pjsua-log" registered
18:43:21.731 sip_endpoint.c  .Module "mod-tsx-layer" registered
18:43:21.731 sip_endpoint.c  .Module "mod-stateful-util" registered
18:43:21.731 sip_endpoint.c  .Module "mod-ua" registered
18:43:21.731 sip_endpoint.c  .Module "mod-100rel" registered
18:43:21.731 sip_endpoint.c  .Module "mod-pjsua" registered
18:43:21.731 sip_endpoint.c  .Module "mod-invite" registered
18:43:21.803       pa_dev.c  ..PortAudio sound library initialized, status=0
18:43:21.803       pa_dev.c  ..PortAudio host api count=2
18:43:21.803       pa_dev.c  ..Sound device count=8
18:43:21.803          pjlib  ..select() I/O Queue created (0x69cc38)
18:43:21.815    pjsua_vid.c  ..Initializing video subsystem..
18:43:21.873     v4l2_dev.c  ...Video4Linux2 has 1 devices
18:43:22.101      sdl_dev.c  ...SDL 2.0 initialized
18:43:22.101 colorbar_dev.c  ...Colorbar video src initialized with 2
device(s):
18:43:22.101 colorbar_dev.c  ... 0: Colorbar generator
18:43:22.101 colorbar_dev.c  ... 1: Colorbar-active
18:43:22.101 sip_endpoint.c  .Module "mod-evsub" registered
18:43:22.101 sip_endpoint.c  .Module "mod-presence" registered
18:43:22.101 sip_endpoint.c  .Module "mod-mwi" registered
18:43:22.101 sip_endpoint.c  .Module "mod-refer" registered
18:43:22.101 sip_endpoint.c  .Module "mod-pjsua-pres" registered
18:43:22.101 sip_endpoint.c  .Module "mod-pjsua-im" registered
18:43:22.101 sip_endpoint.c  .Module "mod-pjsua-options" registered
18:43:22.102   pjsua_core.c  .1 SIP worker threads created
18:43:22.102   pjsua_core.c  .pjsua version 2.4.5 for
Linux-3.16.6/x86_64/glibc-2.19 initialized
18:43:22.102   pjsua_core.c  .PJSUA state changed: CREATED --> INIT
18:43:22.102      logtest.c  pj_log message 2
-> calling pj_log_set_decor() again!
-> calling pj_log_set_level() again!
-> calling pj_log_set_log_func() again!
log callback: --> INFO: pj_log message 3<--
-> calling pjsua_start()
log callback: -->DEBUG: PJSUA state changed: INIT --> STARTING<--
log callback: -->DEBUG: .Module "mod-unsolicited-mwi" registered<--
log callback: -->DEBUG: .PJSUA state changed: STARTING --> RUNNING<--
log callback: --> INFO: pj_log message 4<--
-> calling pjsua_destroy()
log callback: -->DEBUG: Shutting down, flags=0...<--
log callback: -->DEBUG: PJSUA state changed: RUNNING --> CLOSING<--
log callback: -->DEBUG: .Hangup all calls..<--
log callback: -->DEBUG: .Call 0: deinitializing media..<--
log callback: -->DEBUG: .Call 1: deinitializing media..<--
log callback: -->DEBUG: .Call 2: deinitializing media..<--
log callback: -->DEBUG: .Call 3: deinitializing media..<--
log callback: -->DEBUG: .Shutting down presence..<--
log callback: -->DEBUG: .Destroying...<--
log callback: -->DEBUG: .Shutting down media..<--
log callback: -->DEBUG: ..Destroying video subsystem..<--
log callback: -->DEBUG: ...Window 0: destroying..<--
log callback: -->DEBUG: ...Window 1: destroying..<--
log callback: -->DEBUG: ...Window 2: destroying..<--
log callback: -->DEBUG: ...Window 3: destroying..<--
log callback: -->DEBUG: ...Window 4: destroying..<--
log callback: -->DEBUG: ...Window 5: destroying..<--
log callback: -->DEBUG: ...Window 6: destroying..<--
log callback: -->DEBUG: ...Window 7: destroying..<--
log callback: -->DEBUG: ...Window 8: destroying..<--
log callback: -->DEBUG: ...Window 9: destroying..<--
log callback: -->DEBUG: ...Window 10: destroying..<--
log callback: -->DEBUG: ...Window 11: destroying..<--
log callback: -->DEBUG: ...Window 12: destroying..<--
log callback: -->DEBUG: ...Window 13: destroying..<--
log callback: -->DEBUG: ...Window 14: destroying..<--
log callback: -->DEBUG: ...Window 15: destroying..<--
log callback: -->DEBUG: ..PortAudio sound library shutting down..<--
log callback: -->DEBUG: .Stopping transaction layer module<--
log callback: -->DEBUG: .Stopped transaction layer module<--
log callback: -->DEBUG: .Module "mod-unsolicited-mwi" unregistered<--
log callback: -->DEBUG: .Module "mod-pjsua-options" unregistered<--
log callback: -->DEBUG: .Module "mod-pjsua-im" unregistered<--
log callback: -->DEBUG: .Module "mod-pjsua-pres" unregistered<--
log callback: -->DEBUG: .Module "mod-pjsua" unregistered<--
log callback: -->DEBUG: .Module "mod-stateful-util" unregistered<--
log callback: -->DEBUG: .Module "mod-refer" unregistered<--
log callback: -->DEBUG: .Module "mod-mwi" unregistered<--
log callback: -->DEBUG: .Module "mod-presence" unregistered<--
log callback: -->DEBUG: .Module "mod-evsub" unregistered<--
log callback: -->DEBUG: .Module "mod-invite" unregistered<--
log callback: -->DEBUG: .Module "mod-100rel" unregistered<--
log callback: -->DEBUG: .Module "mod-ua" unregistered<--
log callback: -->DEBUG: .Transaction layer module destroyed<--
log callback: -->DEBUG: .Module "mod-tsx-layer" unregistered<--
log callback: -->DEBUG: .Module "mod-msg-print" unregistered<--
log callback: -->DEBUG: .Module "mod-pjsua-log" unregistered<--
log callback: -->DEBUG: .Endpoint 0x620c38 destroyed<--
log callback: -->DEBUG: .PJSUA state changed: CLOSING --> NULL<--
log callback: -->DEBUG: .PJSUA destroyed...<--
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20150901/7b0a101b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: logtest.c
Type: text/x-csrc
Size: 1582 bytes
Desc: not available
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20150901/7b0a101b/attachment.c>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux