sangoma / switchy

async FreeSWITCH cluster control
https://switchy.readthedocs.io/en/latest/
Mozilla Public License 2.0
69 stars 18 forks source link

Per thread oriented logging should indicate the thread name/id #11

Closed goodboy closed 7 years ago

goodboy commented 8 years ago

Currently the only way to differentiate each thread by log messages is by knowing that there is a separate thread per observer / slave. Ex:

Aug 19 17:45:48 [DEBUG] switchy.EventListener@vm-host.qa.sangoma.local observe.py:901 : all sessions for call 'a4a34890-46bb-11e5-8351-74d02bc595d7' were hung up
Aug 19 17:46:08 [DEBUG] switchy.EventListener@sip-cannon.qa.sangoma.local observe.py:544 : receive event 'CHANNEL_HANGUP'

The only indicator is the slave's hostname info found after the class name which for this example are vm-host and sip-cannon respectively.

There should probably be an additional indicator (maybe the thread id?) such that a user knows immediately from which thread a message has been emitted. This is handy especially when reading messages from the Originator burst loop thread which, currently has no indicator other then it being different in format then the observer produced messages.

It usually looks something like:

Aug 19 17:45:43 [DEBUG] switchy.Originator@['vm-host.qa.sangoma.local', 'sip-cannon.qa.sangoma.local'] call_gen.py:418 : count calls = 0
moises-silva commented 8 years ago

Look into:

%(thread)d %(threadName)s

From https://docs.python.org/2/library/logging.html