Unidata / LDM

The Unidata Local Data Manager (LDM) system includes network client and server programs designed for event-driven data distribution, and is the fundamental component of the Unidata Internet Data Distribution (IDD) system.
http://www.unidata.ucar.edu/software/ldm
Other
43 stars 27 forks source link

Add thread-ID to log messages #46

Closed semmerson closed 8 years ago

semmerson commented 9 years ago

With the advent of the multicast feature, multiple threads are logging and it would be beneficial to support greping the messages for those from a particular thread as well as differentiating messages from different threads.

This can be done by invoking pthread_once() in ulog.c to create a THREAD_ID key, setting the value of the key to a mutex-protected, automatically-incremented integer, and then including the integral value in a message prefix (e.g., (file,line,thread-ID)).

Unfortunately, creating an elegant message prefix would seem to require modifications to both ulog.c and log.c: either ulog.c would have to know about incoming messages from log.c or the messaging functions of ulog.c would have to become macros.

Could the PID be added to the tuple? E.g., (PID,TID,file,line). This would break backward compatibility in terms of message format.

semmerson commented 8 years ago

Unfortunately, the type of a thread-ID is not specified by the Unix standard; consequently, formatting one is problematical.