[nanny] logging support to nanny service



commit 6ddd5b5ce1c7a8fc7e2c1ece27e19f4814d0b0c6
Author: Roberto Majadas <roberto majadas openshine com>
Date:   Fri Oct 29 12:18:03 2010 +0200

    logging support to nanny service

 daemon/NannyService.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/daemon/NannyService.py b/daemon/NannyService.py
index 86a4378..dec4cb8 100644
--- a/daemon/NannyService.py
+++ b/daemon/NannyService.py
@@ -64,6 +64,8 @@ class NannyService (win32serviceutil.ServiceFramework):
     def __init__(self,args):
         win32serviceutil.ServiceFramework.__init__(self,args)
         self.hWaitStop = win32event.CreateEvent(None,0,0,None)
+        self.log = open(os.path.join(os.environ["ALLUSERSPROFILE"], "Gnome", "nanny", "nanny.log"), "w")
+
 
     def SvcStop(self):
         self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
@@ -75,6 +77,8 @@ class NannyService (win32serviceutil.ServiceFramework):
                               (self._svc_name_,''))
         self.CheckForQuit()
         pythoncom.CoInitialize()
+        sys.stdout = self.log
+        sys.stderr = self.log
         self.main()
 
     def CheckForQuit(self):
@@ -82,6 +86,7 @@ class NannyService (win32serviceutil.ServiceFramework):
             if not retval == win32event.WAIT_TIMEOUT:
                 # Received Quit from Win32
                 reactor.stop()
+                self.log.close()
                 pythoncom.CoUninitialize()
                 
             reactor.callLater(1.0, self.CheckForQuit)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]