@@ -383,15 +383,20 @@ def _oneloop(self):
383383 self ._shunt .enqueue (msg , msgdata )
384384 continue
385385
386- msgid = msg .get ('message-id' , 'n/a' )
386+ # Try to get message-id early for logging purposes
387+ try :
388+ msgid = msg .get ('message-id' , 'n/a' )
389+ except Exception as e :
390+ msgid = 'unknown'
391+ mailman_log ('error' , 'IncomingRunner._oneloop: Error getting message-id for file %s: %s' , filebase , str (e ))
387392
388393 # Get the list name
389394 listname = msgdata .get ('listname' , 'unknown' )
390395 try :
391396 mlist = MailList .MailList (listname , lock = False )
392397 except Errors .MMUnknownListError :
393- mailman_log ('error' , 'IncomingRunner._oneloop: Unknown list %s for message %s' ,
394- listname , msgid )
398+ mailman_log ('error' , 'IncomingRunner._oneloop: Unknown list %s for message %s (file: %s) ' ,
399+ listname , msgid , filebase )
395400 self ._shunt .enqueue (msg , msgdata )
396401 continue
397402
@@ -402,14 +407,15 @@ def _oneloop(self):
402407 # If the message should be kept in the queue, requeue it
403408 if result :
404409 self ._switchboard .enqueue (msg , msgdata )
405- mailman_log ('info' , 'IncomingRunner._oneloop: Message requeued for later processing: %s' , filebase )
410+ mailman_log ('info' , 'IncomingRunner._oneloop: Message requeued for later processing: %s (msgid: %s)' ,
411+ filebase , msgid )
406412 else :
407413 mailman_log ('info' , 'IncomingRunner._oneloop: Message processing complete, moving to shunt queue %s (msgid: %s)' ,
408414 filebase , msgid )
409415
410416 except Exception as e :
411- mailman_log ('error' , 'IncomingRunner._oneloop: Error processing message: %s\n %s' ,
412- str (e ), traceback .format_exc ())
417+ mailman_log ('error' , 'IncomingRunner._oneloop: Error processing message %s (file: %s) : %s\n %s' ,
418+ msgid , filebase , str (e ), traceback .format_exc ())
413419 # Move to shunt queue on error
414420 self ._shunt .enqueue (msg , msgdata )
415421
0 commit comments