signalwire / freeswitch

FreeSWITCH is a Software Defined Telecom Stack enabling the digital transformation from proprietary telecom switches to a versatile software implementation that runs on any commodity hardware. From a Raspberry PI to a multi-core server, FreeSWITCH can unlock the telecommunications potential of any device.
https://freeswitch.com/#getting-started
Other
3.48k stars 1.4k forks source link

Output the SIP call-id with the FreeSWITCH logs #839

Open khou opened 4 years ago

khou commented 4 years ago

I'm trying to correlate FreeSWITCH application logs with SIP I'm capturing using Heplify.

If possible, an enhancement to logging where the call-id is logged with each line of the application log would make it much easier to identify what occurs in FreeSWITCH for a specific call.

I've attempted this with channel UUID and capturing the CDR, then correlating the SIP with the CDR, but as you can see, this is an extensive workaround and requires lots of custom logic.

Desired output sample:

2020-09-01T20:33:58Z INFO HEP packet:{Version:2,Protocol:17,SrcIP:192.168.63.171,DstIP:192.168.63.6,SrcPort:15060,DstPort:41963,Tsec:1598992438,Tmsec:270403,ProtoType:1,NodeID:2002,NodePW:,CID:,Vlan:0} with Payload:
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.63.6:41963;rport=41963;branch=z9hG4bKPj2911369f-24eb-4731-b915-7cde4dbfa3b9
From: <sip:1018@freeswitch-internal>;tag=cba407e1-3d14-497f-97b2-c0efae925577
To: <sip:1019@freeswitch-internal>;tag=v2K9tQpaUrQKj
Call-ID: dedf359c-fd65-4df4-a512-1b05747a1b6d
CSeq: 9211 BYE
User-Agent: FreeSWITCH-mod_sofia/1.10.2-release-14-f7bdd3845a~64bit
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Content-Length: 0
Session-ID: 00000000000000000000000000000000

dedf359c-fd65-4df4-a512-1b05747a1b6d 2020-09-01 20:33:58.252944 [INFO] sofia_glue.c:545 Setting "Session-ID: 058092b0134449418b09e2df389e06a5" from partner leg
dedf359c-fd65-4df4-a512-1b05747a1b6d 2020-09-01 20:33:58.252944 [WARNING] sofia_glue.c:588 Session-ID: Fallback to RFC7329
dedf359c-fd65-4df4-a512-1b05747a1b6d 2020-09-01 20:33:58.252944 [NOTICE] sofia.c:1089 Hangup sofia/internal/1018@freeswitch-internal [CS_EXECUTE] [NORMAL_CLEARING]
dedf359c-fd65-4df4-a512-1b05747a1b6d 2020-09-01 20:33:58.252944 [DEBUG] switch_ivr_bridge.c:823 sofia/internal/1018@freeswitch-internal ending bridge by request from write function

This applies to all versions of FreeSWITCH

seven1240 commented 4 years ago

for inbound calls, you can just log the call id when INVITE is received. for outbound calls, enable use-uuid-as-call-id in sip profile should be enough.

suggest add call-id to the following log line e.g.

d9edda4b-52c5-49f0-a22e-94ab45418777 2020-09-02 16:14:10.639073 [DEBUG] sofia.c:10324 sofia/default/1007@seven.local receiving invite from 172.22.0.1:48789 version: 1.10.4-dev git 9a78d18 2020-08-20 07:07:29Z 64bit call-id: xxxx
seven1240 commented 3 years ago

see https://github.com/signalwire/freeswitch/pull/1034/files