Index: trunk/Monitoring/Watch/watch
===================================================================
--- trunk/Monitoring/Watch/watch	(revision 965)
+++ trunk/Monitoring/Watch/watch	(revision 966)
@@ -18,5 +18,4 @@
 import sys
 import signal
-import traceback
 import smtplib
 from email.mime.text import MIMEText
@@ -37,8 +36,31 @@
 CSTE_LOG_FILENAME_MSG='message.log' # log AMQP msgs
 CSTE_LOG_FILE_MAIN="%s/%s"%(CSTE_LOG_DIR,CSTE_LOG_FILENAME_MAIN)
-
-# logger init.
-logging.basicConfig(filename=CSTE_LOG_FILE_MAIN,level=logging.INFO,)
-
+CSTE_LOG_FILE_MSG="%s/%s"%(CSTE_LOG_DIR,CSTE_LOG_FILENAME_MSG)
+
+def create_logger(name,fullpath_filename):
+
+	# new logger instance
+	logger = logging.getLogger(name)
+	logger.setLevel(logging.DEBUG)
+
+	# create associated file
+	fh = logging.FileHandler(fullpath_filename)
+	fh.setLevel(logging.DEBUG)
+
+	# create formatter
+	formatter = logging.Formatter('%(asctime)-15s - %(message)s')
+	fh.setFormatter(formatter)
+
+	# binding
+	logger.addHandler(fh)
+
+	return logger
+
+
+
+
+# loggers init.
+logger=create_logger(CSTE_LOG_FILENAME_MAIN,CSTE_LOG_FILE_MAIN)
+msg_logger=create_logger(CSTE_LOG_FILENAME_MSG,CSTE_LOG_FILE_MSG)
 
 class Mail():
@@ -81,5 +103,4 @@
 
 		except:
-			traceback.print_exc()
 			raise
 
@@ -100,5 +121,4 @@
 
 		except:
-			traceback.print_exc()
 			raise
 
@@ -144,5 +164,5 @@
 	def log_msg(cls,message):
 		line="%s %s %s %s"%(message.code,message.jobid,message.timestamp,message.command)
-		cls.log(CSTE_LOG_FILENAME_MSG,line)
+		msg_logger.info(line)
 
 		"""
@@ -164,12 +184,10 @@
 				getattr(Actions, proc_name)(message)
 			except Exception,e:
-				traceback.print_exc()
-
-				raise Exception("WATCH-ERR002","procedure error (%s,%s)"%(proc_name,str(e)))
+				logger.exception("ERR909 - exception occurs")
+
+				raise Exception("WATCH-ERR002","procedure error (%s)"%(proc_name,))
 
 class MessageActionsMapping():
 
-	# debug
-	#
 	# TAG0001: note that crea_sim must be BEFORE store_msg in the list (because when we insert the msg, we need the simu_id)
 	#
@@ -180,20 +198,11 @@
 				"2000":["log_msg", "store_msg"],
 				"3000":["log_msg", "store_msg"],
+				"7000":["log_msg"],
 				"8888":["cleanup"],
 				"9000":["log_msg", "store_msg"],
 				"9999":["log_msg", "store_msg", "set_sim_status_to_error"] }
 
-	# prod
-	#
-	# TAG0001: note that crea_sim must be BEFORE store_msg in the list (because when we insert the msg, we need the simu_id)
-	#
+	# prod (mail added for some action)
 	"""
-	mapping = { "0000":["crea_sim", "log_msg", "store_msg"],
-				"0100":["log_msg", "store_msg", "set_sim_status_to_complete"],
-				"1000":["log_msg", "store_msg"],
-				"1100":["log_msg", "store_msg"],
-				"2000":["log_msg", "store_msg"],
-				"3000":["log_msg", "store_msg"],
-				"8888":["cleanup"],
 				"9000":["log_msg", "store_msg", "mail"],
 				"9999":["log_msg", "store_msg", "set_sim_status_to_error", "mail"] }
@@ -229,5 +238,5 @@
 		self.channel = connection.channel()
 
-		logging.info("[*] Waiting for messages")
+		logger.info("[*] Waiting for messages")
 
 		def callback(ch, method, properties, raw_msg):
@@ -247,5 +256,5 @@
 
 				# debug
-				#logging.debug(" [x] Received %s"%field)
+				#logger.debug(" [x] Received %s"%field)
 
 				splitted_field=field.split(":")
@@ -258,5 +267,5 @@
 
 			# debug
-			#logging.debug(" [x] Received %s (encoded)" % l__tmp_dic["body"])
+			#logger.debug(" [x] Received %s (encoded)" % l__tmp_dic["body"])
 
 			
@@ -266,7 +275,7 @@
 
 			# debug
-			#logging.debug(" [x] Received %s" % raw_msg)
-			#logging.debug(" [x] Received %s (uudecoded)" % base64_decoded_msg )
-			#logging.debug(" [x] Received %s (uudecoded)" % base64_decoded_msg )
+			#logger.debug(" [x] Received %s" % raw_msg)
+			#logger.debug(" [x] Received %s (uudecoded)" % base64_decoded_msg )
+			#logger.debug(" [x] Received %s (uudecoded)" % base64_decoded_msg )
 
 
@@ -278,8 +287,8 @@
 
 				# non working
-				#logging.debug("DEB003 - %s"%message.type)
+				#logger.debug("DEB003 - %s"%message.type)
 
 				# working
-				#logging.debug("DEB009 - %s"%message.code)
+				#logger.debug("DEB009 - %s"%message.code)
 
 
@@ -287,5 +296,5 @@
 			except Exception,e:
 
-				logging.exception("ERR009 - exception occurs (exception=%s)"%(str(e),))
+				logger.exception("ERR009 - exception occurs")
 
 				Actions.log_debug("DEB021 - %s"%base64_decoded_msg) 
@@ -313,5 +322,5 @@
 
 			except Exception,e:
-				logging.exception("ERR019 - exception occurs (exception=%s)"%(str(e),))
+				logger.exception("ERR019 - exception occurs")
 
 				Actions.log_debug("DEB020 - %s"%base64_decoded_msg) 
@@ -323,5 +332,5 @@
 			#time.sleep(0.5)
 
-		self.channel.queue_declare(queue='myqueue')
+		self.channel.queue_declare(queue='myqueue',durable=True)
 
 		self.channel.basic_consume(callback, queue='myqueue', no_ack=True)
@@ -335,5 +344,5 @@
 
 def signal_handler(signal, frame):
-		logging.info("TERM signal received: exiting.")
+		logger.info("TERM signal received: exiting.")
 		Watcher.channel.stop_consuming()
 		Watcher.stop()
@@ -357,5 +366,5 @@
 	except Exception, e:
 
-		traceback.print_exc()
+		logger.exception("ERR904 - exception occurred")
 
 		sys.exit(1)
