Author: remi
Date: 2009-05-28 12:10:04 +0200 (Thu, 28 May 2009)
New Revision: 4693

Modified:
   
software_suite_v3/smart-core/smart-server/trunk/resources/00_smart_server_base/10_resourceScheduler.py
Log:
* added a logger in the scheduler resource

Modified: 
software_suite_v3/smart-core/smart-server/trunk/resources/00_smart_server_base/10_resourceScheduler.py
===================================================================
--- 
software_suite_v3/smart-core/smart-server/trunk/resources/00_smart_server_base/10_resourceScheduler.py
      2009-05-28 09:44:17 UTC (rev 4692)
+++ 
software_suite_v3/smart-core/smart-server/trunk/resources/00_smart_server_base/10_resourceScheduler.py
      2009-05-28 10:10:04 UTC (rev 4693)
@@ -7,6 +7,7 @@
 
 from util.scheduler.Scheduler import Scheduler
 from util.scheduler.Task import *
+from util.logger.SimpleLogger import *
 
 # Scheduler manager events/statuses
 ST_NAME_SCM_TASK_ADDED = "scheduler_manager_task_added"
@@ -57,7 +58,19 @@
         # Registering the scheduler manager statuses.
         for statusName in SW_NAME_SCHEDULER_MANAGER:
             eventsHandler.insert(statusName)
+        # Create a logger
+        self.logger = SimpleLogger("scs_scheduler")
+        self.logger.resetLog()
+        self.logger.setLevel(TDS_CONF_LOG_LEVEL)
+        self.logger.setTarget(TDS_CONF_LOG_TARGET)
+        self.logger.logInfo("-----------------------------------------------")
+        self.logger.logInfo("Smart-core Scheduler")
+        self.logger.logInfo("Licence : GPL")
+        self.logger.logInfo("-----------------------------------------------")
+        # Start the scheduler
+        self.logger.logInfo("Starting the scheduler.")
         self.__scheduler.start()
+        self.logger.logInfo("Scheduler is started.")
 
     # 
--------------------------------------------------------------------------
     # Stop the resource.
@@ -65,7 +78,9 @@
     def stop(self):
         """Stop the resource.
         """
+        self.logger.logInfo("Stopping the scheduler.")
         self.__scheduler.stop()
+        self.logger.logInfo("Scheduler is stopped.")
 
     # 
==========================================================================
     # Private methods
@@ -80,7 +95,7 @@
         """
         taskName = task.getDescription().getName()
         taskDesc = task.getDescription().toString()
-        print "Task added :", taskName, taskDesc
+        self.logger.logInfo("Task added [%s] : %s" % (taskName, taskDesc))
         resourceStatus.publishEvents(False, ST_NAME_SCM_TASK_ADDED,
             [task.getDescription().getId(), task.getDescription().getName()])
 
@@ -91,7 +106,9 @@
         """Event on task removed.
         @param task: Task object.
         """
-        print "Task removed :", task.getDescription().toString()
+        taskName = task.getDescription().getName()
+        taskDesc = task.getDescription().toString()
+        self.logger.logInfo("Task removed [%s] : %s" % (taskName, taskDesc))
         resourceStatus.publishEvents(False, ST_NAME_SCM_TASK_REMOVED,
             [task.getDescription().getId(), task.getDescription().getName()])
 
@@ -101,7 +118,7 @@
     def __onTasksLoaded(self):
         """Event on tasks loaded.
         """
-        print "Tasks loaded"
+        self.logger.logInfo("Tasks container is loaded")
         resourceStatus.publishEvents(True, ST_NAME_SCM_TASKS_LOADED, ["True",])
 
     # 
--------------------------------------------------------------------------
@@ -110,7 +127,7 @@
     def __onTasksUnloaded(self):
         """Event on tasks unloaded.
         """
-        print "Tasks unloaded"
+        self.logger.logInfo("Tasks container is unloaded")
         resourceStatus.publishEvents(True, ST_NAME_SCM_TASKS_UNLOADED,
             ["True",])
 


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to