Index: trunk/email2trac.py.in
===================================================================
--- trunk/email2trac.py.in	(revision 415)
+++ trunk/email2trac.py.in	(revision 416)
@@ -365,7 +365,6 @@
 		#
 		if self.DROP_SPAM and spam:
-			if self.parameters.debug > 2 : 
-				set.logger.debug('Message is a SPAM. Automatic ticket insertion refused (SPAM level > %d)' % self.SPAM_LEVEL)
-
+
+			set.logger.info('Message is a SPAM. Automatic ticket insertion refused (SPAM level > %d)' % self.SPAM_LEVEL)
 			return 'drop'	
 
@@ -373,5 +372,4 @@
 
 			return 'Spam'	
-
 		else:
 
@@ -394,6 +392,5 @@
 
 		except KeyError, detail:
-			if self.parameters.debug > 2 :
-				self.logger.debug('%s not defined, all messages are allowed.' %(keyword))
+			self.logger.debug('%s not defined, all messages are allowed.' %(keyword))
 
 			return default 
@@ -505,6 +502,5 @@
 
 				if addr == self.trac_smtp_from:
-					if self.parameters.debug:
-						self.logger.debug("Skipping %s mail address for CC-field" %(addr))
+					self.logger.debug("Skipping %s mail address for CC-field" %(addr))
 					continue
 
@@ -515,6 +511,5 @@
 
 			if email_cc:
-				if self.parameters.debug:
-						self.logger.debug('set_reply_fields: %s' %email_cc)
+				self.logger.debug('set_reply_fields: %s' %email_cc)
 
 				ticket['cc'] = self.email_to_unicode(email_cc)
@@ -709,6 +704,5 @@
 
 		if tkt['reporter'].lower() in [self.author, self.email_addr]:
-			if self.parameters.debug:
-				self.logger.debug('ALLOW, %s is the ticket reporter' %(self.email_addr))
+			self.logger.debug('ALLOW, %s is the ticket reporter' %(self.email_addr))
 
 			return True
@@ -716,6 +710,5 @@
 		perm = PermissionSystem(self.env)
 		if perm.check_permission('TICKET_MODIFY', self.author):
-			if self.parameters.debug:
-				self.logger.debug('ALLOW, %s has trac permission to update the ticket' %(self.author))
+			self.logger.debug('ALLOW, %s has trac permission to update the ticket' %(self.author))
 
 			return True
@@ -730,7 +723,5 @@
 			for cc in cc_list:
 				if self.email_addr.lower() in cc.strip():
-
-					if self.parameters.debug:
-						self.logger.debug('ALLOW, %s is in the CC' %(self.email_addr))
+					self.logger.debug('ALLOW, %s is in the CC' %(self.email_addr))
 
 					return True
@@ -811,6 +802,5 @@
 
 				if self.trac_smtp_from in cc_list:
-					if self.parameters.debug:
-						self.logger.debug('TD: MAIL LOOP: %s is not allowed as CC address' %(self.trac_smtp_from))
+					self.logger.debug('TD: MAIL LOOP: %s is not allowed as CC address' %(self.trac_smtp_from))
 
 					cc_list.remove(self.trac_smtp_from)
@@ -930,11 +920,8 @@
 				fields = controller.get_ticket_changes(req, tkt, self.WORKFLOW)
 
-				if self.parameters.debug:
-					self.logger.debug('Workflow ticket update fields: ')
+				self.logger.debug('Workflow ticket update fields: ')
 
 				for key in fields.keys():
-					if self.parameters.debug:
-						self.logger.debug('\t %s : %s' %(key, fields[key]))
-
+					self.logger.debug('\t %s : %s' %(key, fields[key]))
 					tkt[key] = fields[key]
 
@@ -1006,5 +993,5 @@
 	
 			if self.parameters.debug:
-				s = 'TD: trac.ini name %s = %s' %(name, value)
+				s = 'trac[%s] = %s' %(name, value)
 				self.print_unicode(s)
 
@@ -1015,5 +1002,5 @@
 				value = self.parameters['%s_%s' %(prefix, name)]
 				if self.parameters.debug > 10:
-					s = 'TD: email2trac.conf %s = %s ' %(name, value)
+					s = 'email2trac[%s] = %s ' %(name, value)
 					self.print_unicode(s)
 
@@ -1022,5 +1009,5 @@
 		
 			if self.parameters.debug:
-				s = 'TD: user_dict[%s] = %s' %(name, value)
+				s = 'used %s = %s' %(name, value)
 				self.print_unicode(s)
 
@@ -1055,6 +1042,5 @@
 				orig_subject = result.group(3)
 
-				if self.parameters.debug:
-					self.logger.debug('subject search string: %s' %(orig_subject))
+				self.logger.debug('subject search string: %s' %(orig_subject))
 
 				cursor = self.db.cursor()
@@ -1068,6 +1054,5 @@
 
 				for summary in summaries:
-					if self.parameters.debug:
-						self.logger.debug('Looking for summary matching: "%s"' % summary)
+					self.logger.debug('Looking for summary matching: "%s"' % summary)
 
 					sql = """SELECT id FROM ticket
@@ -1079,6 +1064,5 @@
 						(matched_id,) = row
 
-						if self.parameters.debug:
-							self.logger.debug('Found matching ticket id: %d' % matched_id)
+						self.logger.debug('Found matching ticket id: %d' % matched_id)
 
 						break
@@ -1335,6 +1319,5 @@
 		from trac.util.datefmt import to_timestamp, utc
 
-		if self.parameters.debug:
-			self.logger.debug('Creating a new topic in forum:', self.id)
+		self.logger.debug('Creating a new topic in forum:', self.id)
 
 		# Get dissussion API component.
@@ -1345,6 +1328,6 @@
 		forum = api.get_forum(context, self.id)
 
-		if not forum and self.parameters.debug:
-			self.logger.debug("ERROR: Replied forum doesn't exist")
+		if not forum:
+			self.logger.error("ERROR: Replied forum doesn't exist")
 
 		# Prepare topic.
@@ -1366,6 +1349,5 @@
 		from trac.util.datefmt import to_timestamp, utc
 
-		if self.parameters.debug:
-			self.logger.debug('Replying to discussion topic', self.id)
+		self.logger.debug('Replying to discussion topic', self.id)
 
 		# Get dissussion API component.
@@ -1376,6 +1358,6 @@
 		topic = api.get_topic(context, self.id)
 
-		if not topic and self.parameters.debug:
-			self.logger.debug("ERROR: Replied topic doesn't exist")
+		if not topic:
+			self.logger.error("ERROR: Replied topic doesn't exist")
 
 		# Prepare message.
@@ -1397,6 +1379,5 @@
 		from trac.util.datefmt import to_timestamp, utc
 
-		if self.parameters.debug:
-			self.loggger.debug('TD: Replying to discussion message', self.id)
+		self.loggger.debug('TD: Replying to discussion message', self.id)
 
 		# Get dissussion API component.
@@ -1407,6 +1388,6 @@
 		message = api.get_message(context, self.id)
 
-		if not message and self.parameters.debug:
-			self.logger.debug("ERROR: Replied message doesn't exist")
+		if not message:
+			self.logger.error("ERROR: Replied message doesn't exist")
 
 		# Prepare message.
@@ -1529,7 +1510,5 @@
 		
 		if not m:
-			if self.parameters.debug:
-				self.logger.debug('This is not a valid email message format')
-
+			self.logger.debug('This is not a valid email message format')
 			return
 			
@@ -1547,19 +1526,13 @@
 
 		if not self.email_header_acl('white_list', self.email_addr, True):
-			if self.parameters.debug:
-				self.logger.debug('Message rejected : %s not in white list' %(self.email_addr))
-
+			self.logger.info('Message rejected : %s not in white list' %(self.email_addr))
 			return False
 
 		if self.email_header_acl('black_list', self.email_addr, False):
-			if self.parameters.debug:
-				self.logger.debug('Message rejected : %s in black list' %(self.email_addr))
-
+			self.logger.info('Message rejected : %s in black list' %(self.email_addr))
 			return False
 
 		if not self.email_header_acl('recipient_list', self.to_email_addr, True):
-			if self.parameters.debug:
-				self.logger.debug('Message rejected : %s not in recipient list' %(self.to_email_addr))
-
+			self.logger.info('Message rejected : %s not in recipient list' %(self.to_email_addr))
 			return False
 
@@ -1579,6 +1552,5 @@
 			subject  = self.email_to_unicode(m['Subject'])
 
-		if self.parameters.debug:
-			self.logger.debug('subject: %s' %subject)
+		self.logger.debug('subject: %s' %subject)
 
 		#
@@ -1754,6 +1726,6 @@
 				self.properties[keyword] = value.strip()
 
-				if self.parameters.debug:
-					self.logger.debug('inline properties: %s : %s' %(keyword,value))
+				self.logger.debug('inline properties: %s : %s' %(keyword,value))
+
 			else:
 				body.append(line)
@@ -1807,15 +1779,11 @@
 
 		for part in msg.walk():
-			if self.parameters.debug:
-				self.logger.debug('Message part: Main-Type: %s' % part.get_content_maintype())
-				self.logger.debug('Message part: Content-Type: %s' % part.get_content_type())
+			self.logger.debug('Message part: Main-Type: %s' % part.get_content_maintype())
+			self.logger.debug('Message part: Content-Type: %s' % part.get_content_type())
 
 			## Check content type
 			# 
 			if part.get_content_type() in self.STRIP_CONTENT_TYPES:
-
-				if self.parameters.debug:
-					self.logger.debug("A %s attachment named '%s' was skipped" %(part.get_content_type(), part.get_filename()))
-
+				self.logger.debug("A %s attachment named '%s' was skipped" %(part.get_content_type(), part.get_filename()))
 				continue
 
@@ -1829,6 +1797,6 @@
 			#
 			if part.get_content_maintype() == 'multipart':
-				if self.parameters.debug:
-					self.logger.debug("Skipping multipart container")
+				self.logger.debug("Skipping multipart container")
+
 				continue
 			
@@ -1841,8 +1809,6 @@
 			if ALTERNATIVE_MULTIPART and self.DROP_ALTERNATIVE_HTML_VERSION:
 				if part.get_content_type() == 'text/html':
-					if self.parameters.debug:
-						self.logger.debug('Skipping alternative HTML message')
-
-			        	ALTERNATIVE_MULTIPART = False
+					self.logger.debug('Skipping alternative HTML message')
+					ALTERNATIVE_MULTIPART = False
 					continue
 
@@ -1850,6 +1816,5 @@
 			#
 			if part.get_content_type() == 'text/plain' and inline:
-				if self.parameters.debug:
-					self.logger.debug('               Inline body part')
+				self.logger.debug('               Inline body part')
 
 				# Try to decode, if fails then do not decode
