Skip to content

Commit 8ec04af

Browse files
committed
update code
1 parent cf3a479 commit 8ec04af

5 files changed

Lines changed: 62 additions & 18 deletions

File tree

Mailman/Handlers/CookHeaders.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,35 +103,60 @@ def change_header(name, value, mlist, msg, msgdata, delete=True, repl=True):
103103
Utils.GetCharSet(mlist.preferred_language))
104104

105105
def process(mlist, msg, msgdata):
106+
"""Process the message by cooking its headers."""
107+
msgid = msg.get('message-id', 'n/a')
108+
109+
# Log start of processing with enhanced details
110+
mailman_log('debug', 'CookHeaders: Starting to process message %s for list %s',
111+
msgid, mlist.internal_name())
112+
mailman_log('debug', 'CookHeaders: Message details:')
113+
mailman_log('debug', ' Message ID: %s', msgid)
114+
mailman_log('debug', ' From: %s', msg.get('from', 'unknown'))
115+
mailman_log('debug', ' To: %s', msg.get('to', 'unknown'))
116+
mailman_log('debug', ' Subject: %s', msg.get('subject', '(no subject)'))
117+
mailman_log('debug', ' Message type: %s', type(msg).__name__)
118+
mailman_log('debug', ' Message data: %s', str(msgdata))
119+
mailman_log('debug', ' Pipeline: %s', msgdata.get('pipeline', 'No pipeline'))
120+
106121
# Set the "X-Ack: no" header if noack flag is set
107122
if msgdata.get('noack'):
123+
mailman_log('debug', 'CookHeaders: Setting X-Ack: no for message %s', msgid)
108124
change_header('X-Ack', 'no', mlist, msg, msgdata)
109125

110126
# Save original sender for later
111127
if 'original_sender' not in msgdata:
112128
msgdata['original_sender'] = msg.get_sender()
129+
mailman_log('debug', 'CookHeaders: Saved original sender %s for message %s',
130+
msgdata['original_sender'], msgid)
113131

114132
# Handle subject prefix and other headers
115133
fasttrack = msgdata.get('_fasttrack')
116134
if not msgdata.get('isdigest') and not fasttrack:
117135
try:
136+
mailman_log('debug', 'CookHeaders: Adding subject prefix for message %s', msgid)
118137
prefix_subject(mlist, msg, msgdata)
119-
except (UnicodeError, ValueError):
120-
pass
138+
except (UnicodeError, ValueError) as e:
139+
mailman_log('error', 'CookHeaders: Error adding subject prefix for message %s: %s',
140+
msgid, str(e))
121141

122142
# Mark message as processed
143+
mailman_log('debug', 'CookHeaders: Adding X-BeenThere header for message %s', msgid)
123144
change_header('X-BeenThere', mlist.GetListEmail(),
124145
mlist, msg, msgdata, delete=False)
125146

126147
# Add standard headers
148+
mailman_log('debug', 'CookHeaders: Adding standard headers for message %s', msgid)
127149
change_header('X-Mailman-Version', mm_cfg.VERSION,
128150
mlist, msg, msgdata, repl=False)
129151
change_header('Precedence', 'list',
130152
mlist, msg, msgdata, repl=False)
131153

132154
# Handle From: header munging if needed
133155
if (msgdata.get('from_is_list') or mlist.from_is_list) and not fasttrack:
156+
mailman_log('debug', 'CookHeaders: Munging From header for message %s', msgid)
134157
munge_from_header(mlist, msg, msgdata)
158+
159+
mailman_log('debug', 'CookHeaders: Finished processing message %s', msgid)
135160

136161
def munge_from_header(mlist, msg, msgdata):
137162
"""Munge the From: header for the list.

Mailman/Handlers/ToOutgoing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,17 @@ def process(mlist, msg, msgdata):
3131
"""Process the message by moving it to the outgoing queue."""
3232
msgid = msg.get('message-id', 'n/a')
3333

34-
# Log the start of processing
35-
mailman_log('info', 'ToOutgoing: Starting to process message %s for list %s',
34+
# Log the start of processing with enhanced details
35+
mailman_log('debug', 'ToOutgoing: Starting to process message %s for list %s',
3636
msgid, mlist.internal_name())
37-
38-
# Log message details
3937
mailman_log('debug', 'ToOutgoing: Message details:')
4038
mailman_log('debug', ' Message ID: %s', msgid)
4139
mailman_log('debug', ' From: %s', msg.get('from', 'unknown'))
4240
mailman_log('debug', ' To: %s', msg.get('to', 'unknown'))
4341
mailman_log('debug', ' Subject: %s', msg.get('subject', '(no subject)'))
4442
mailman_log('debug', ' Message type: %s', type(msg).__name__)
4543
mailman_log('debug', ' Message data: %s', str(msgdata))
44+
mailman_log('debug', ' Pipeline: %s', msgdata.get('pipeline', 'No pipeline'))
4645

4746
# Get the outgoing queue
4847
try:
@@ -55,8 +54,9 @@ def process(mlist, msg, msgdata):
5554
# Add the message to the outgoing queue
5655
try:
5756
outgoingq.enqueue(msg, msgdata, listname=mlist.internal_name())
58-
mailman_log('info', 'ToOutgoing: Successfully queued message %s for list %s',
57+
mailman_log('debug', 'ToOutgoing: Successfully queued message %s for list %s',
5958
msgid, mlist.internal_name())
59+
mailman_log('debug', 'ToOutgoing: Message %s is now in outgoing queue', msgid)
6060
except Exception as e:
6161
mailman_log('error', 'ToOutgoing: Failed to enqueue message %s: %s', msgid, str(e))
6262
mailman_log('error', 'ToOutgoing: Traceback:\n%s', traceback.format_exc())

Mailman/OldStyleMemberships.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def __init__(self, mlist):
5050
self.bounce_you_are_disabled_warnings_interval = mm_cfg.DEFAULT_BOUNCE_YOU_ARE_DISABLED_WARNINGS_INTERVAL # Initialize bounce warning interval
5151
self.digest_members = {} # Initialize digest_members dictionary
5252
self.digest_is_default = mm_cfg.DEFAULT_DIGEST_IS_DEFAULT # Initialize digest_is_default attribute
53+
self.mime_is_default_digest = mm_cfg.DEFAULT_MIME_IS_DEFAULT_DIGEST # Initialize mime_is_default_digest attribute
5354

5455
def GetMailmanHeader(self):
5556
"""Return the standard Mailman header HTML for this list."""

Mailman/Queue/OutgoingRunner.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,29 @@ def _dispose(self, mlist, msg, msgdata):
214214
msgid = msg.get('message-id', 'n/a')
215215
filebase = msgdata.get('_filebase', 'unknown')
216216

217+
# Log start of processing with enhanced details
218+
mailman_log('debug', 'OutgoingRunner._dispose: Starting to process message %s (file: %s) for list %s',
219+
msgid, filebase, mlist.internal_name())
220+
mailman_log('debug', 'OutgoingRunner._dispose: Message details:')
221+
mailman_log('debug', ' Message ID: %s', msgid)
222+
mailman_log('debug', ' From: %s', msg.get('from', 'unknown'))
223+
mailman_log('debug', ' To: %s', msg.get('to', 'unknown'))
224+
mailman_log('debug', ' Subject: %s', msg.get('subject', '(no subject)'))
225+
mailman_log('debug', ' Message type: %s', type(msg).__name__)
226+
mailman_log('debug', ' Message data: %s', str(msgdata))
227+
mailman_log('debug', ' Pipeline: %s', msgdata.get('pipeline', 'No pipeline'))
228+
217229
# Check retry count
218230
retry_count = msgdata.get('_retry_count', 0)
219231
if retry_count >= self.MAX_RETRIES:
220-
mailman_log('error', 'Message %s exceeded maximum retries', msgid)
232+
mailman_log('error', 'OutgoingRunner._dispose: Message %s exceeded maximum retries (%d)',
233+
msgid, self.MAX_RETRIES)
221234
return False
222235

223236
with self._processed_lock:
224237
if msgid in self._processed_messages:
225-
mailman_log('error', 'OutgoingRunner: Duplicate message detected: %s (file: %s)', msgid, filebase)
238+
mailman_log('error', 'OutgoingRunner._dispose: Duplicate message detected: %s (file: %s)',
239+
msgid, filebase)
226240
return False
227241

228242
# Clean up old message IDs periodically
@@ -234,7 +248,7 @@ def _dispose(self, mlist, msg, msgdata):
234248
last_retry = self._retry_times.get(msgid, 0)
235249
time_since_last_retry = current_time - last_retry
236250
if time_since_last_retry < self.MIN_RETRY_DELAY:
237-
mailman_log('info', 'OutgoingRunner: Message %s (file: %s) retried too soon, delaying. Time since last retry: %d seconds',
251+
mailman_log('debug', 'OutgoingRunner._dispose: Message %s (file: %s) retried too soon, delaying. Time since last retry: %d seconds',
238252
msgid, filebase, time_since_last_retry)
239253
# Requeue with delay
240254
self.__retryq.enqueue(msg, msgdata)
@@ -246,39 +260,43 @@ def _dispose(self, mlist, msg, msgdata):
246260

247261
try:
248262
# Log start of processing
249-
mailman_log('info', 'OutgoingRunner: Starting to process message %s (file: %s) for list %s',
263+
mailman_log('debug', 'OutgoingRunner._dispose: Starting to process message %s (file: %s) for list %s',
250264
msgid, filebase, mlist.internal_name())
251265

252266
# Validate message type first
253267
msg, success = self._validate_message(msg, msgdata)
254268
if not success:
255-
mailman_log('error', 'Message validation failed for outgoing message %s', msgid)
269+
mailman_log('error', 'OutgoingRunner._dispose: Message validation failed for outgoing message %s', msgid)
256270
with self._processed_lock:
257271
self._processed_messages.remove(msgid)
258272
return False
259273

260274
# Process the message through the delivery module
261275
try:
276+
mailman_log('debug', 'OutgoingRunner._dispose: Calling delivery module process function for message %s', msgid)
262277
self._func(mlist, msg, msgdata)
278+
mailman_log('debug', 'OutgoingRunner._dispose: Successfully processed message %s through delivery module', msgid)
263279
except smtplib.SMTPException as e:
280+
mailman_log('error', 'OutgoingRunner._dispose: SMTP error processing message %s: %s', msgid, str(e))
264281
return self._handle_smtp_error(e, mlist, msg, msgdata)
265282

266283
# Log successful completion
267-
mailman_log('info', 'OutgoingRunner: Successfully processed message %s (file: %s) for list %s',
284+
mailman_log('debug', 'OutgoingRunner._dispose: Successfully processed message %s (file: %s) for list %s',
268285
msgid, filebase, mlist.internal_name())
269286
return True
270287
except Exception as e:
271288
# Enhanced error logging with more context
272-
mailman_log('error', 'Error processing outgoing message %s for list %s: %s',
289+
mailman_log('error', 'OutgoingRunner._dispose: Error processing outgoing message %s for list %s: %s',
273290
msgid, mlist.internal_name(), str(e))
274-
mailman_log('error', 'Message details:')
291+
mailman_log('error', 'OutgoingRunner._dispose: Message details:')
275292
mailman_log('error', ' Message ID: %s', msgid)
276293
mailman_log('error', ' From: %s', msg.get('from', 'unknown'))
277294
mailman_log('error', ' To: %s', msg.get('to', 'unknown'))
278295
mailman_log('error', ' Subject: %s', msg.get('subject', '(no subject)'))
279296
mailman_log('error', ' Message type: %s', type(msg).__name__)
280297
mailman_log('error', ' Message data: %s', str(msgdata))
281-
mailman_log('error', 'Traceback:\n%s', traceback.format_exc())
298+
mailman_log('error', ' Pipeline: %s', msgdata.get('pipeline', 'No pipeline'))
299+
mailman_log('error', 'OutgoingRunner._dispose: Traceback:\n%s', traceback.format_exc())
282300

283301
# Remove from processed messages on error and requeue
284302
with self._processed_lock:

Mailman/Queue/Switchboard.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ def dequeue(self, filebase):
234234

235235
if isinstance(data, tuple):
236236
msg, data = data
237-
mailman_log('debug', 'Switchboard.dequeue: Unpickled tuple with msg type: %s, data type: %s',
237+
mailman_log('debug', 'Switchboard.dequeue: 1Unpickled tuple with msg type: %s, data type: %s',
238238
type(msg), type(data))
239239
else:
240240
msg = None
241-
mailman_log('debug', 'Switchboard.dequeue: Unpickled non-tuple data: %s', type(data))
241+
mailman_log('debug', 'Switchboard.dequeue: 2Unpickled non-tuple data: %s', type(data))
242242

243243
except (pickle.UnpicklingError, ValueError) as e:
244244
mailman_log('debug', 'Switchboard.dequeue: Python 3 protocol failed, trying Python 2 protocol: %s', str(e))

0 commit comments

Comments
 (0)