Update of /cvs-repository/Zope/lib/python/nt_svcutils In directory cvs.zope.org:/tmp/cvs-serv6352
Modified Files: Tag: Zope-2_7-branch service.py Log Message: - Don't kill the service if we can't write to the event log === Zope/lib/python/nt_svcutils/service.py 1.1.2.2 => 1.1.2.3 === --- Zope/lib/python/nt_svcutils/service.py:1.1.2.2 Tue Apr 12 23:41:34 2005 +++ Zope/lib/python/nt_svcutils/service.py Wed Apr 13 21:47:48 2005 @@ -93,24 +93,35 @@ def logmsg(self, event): # log a service event using servicemanager.LogMsg - from servicemanager import LogMsg, EVENTLOG_INFORMATION_TYPE - LogMsg(EVENTLOG_INFORMATION_TYPE, event, - (self._svc_name_, " (%s)" % self._svc_display_name_)) + try: + servicemanager.LogMsg(servicemanager.EVENTLOG_INFORMATION_TYPE, + event, + (self._svc_name_, + " (%s)" % self._svc_display_name_)) + except win32api.error, details: + # Failed to write a log entry - most likely problem is + # that the event log is full. We don't want this to kill us + print "FAILED to write INFO event", event, ":", details + + def _dolog(self, func, msg): + try: + fullmsg = "%s (%s): %s" % \ + (self._svc_name_, self._svc_display_name_, msg) + func(fullmsg) + except win32api.error, details: + # Failed to write a log entry - most likely problem is + # that the event log is full. We don't want this to kill us + print "FAILED to write event log entry:", details + print msg def info(self, s): - from servicemanager import LogInfoMsg - LogInfoMsg("%s (%s): %s" % - (self._svc_name_, self._svc_display_name_, s)) + self._dolog(servicemanager.LogInfoMsg, s) def warning(self, s): - from servicemanager import LogWarningMsg - LogWarningMsg("%s (%s): %s" % - (self._svc_name_, self._svc_display_name_, s)) + self._dolog(servicemanager.LogWarningMsg, s) def error(self, s): - from servicemanager import LogErrorMsg - LogErrorMsg("%s (%s): %s" % - (self._svc_name_, self._svc_display_name_, s)) + self._dolog(servicemanager.LogErrorMsg, s) def SvcDoRun(self): # indicate to Zope that the process is daemon managed (restartable) _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins