Added logging of the calling thread ID and relaxed dependency on global variables for calling filename/linenumber.