[pywin32-checkins] pywin32/win32/Demos eventLogDemo.py,1.6,1.7
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-12-11 06:57:55
|
Update of /cvsroot/pywin32/pywin32/win32/Demos In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1019/win32/Demos Modified Files: eventLogDemo.py Log Message: merge from py3k branch - pass user info when logging records Index: eventLogDemo.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Demos/eventLogDemo.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** eventLogDemo.py 4 Dec 2008 07:22:19 -0000 1.6 --- eventLogDemo.py 11 Dec 2008 06:57:50 -0000 1.7 *************** *** 1,4 **** --- 1,5 ---- import win32evtlog import win32api + import win32con import win32security # To translate NT Sids to account names. *************** *** 83,90 **** verbose = verbose + 1 if do_write: ! win32evtlogutil.ReportEvent(logType, 2, strings=["The message text for event 2"], data = "Raw\0Data") ! win32evtlogutil.ReportEvent(logType, 1, eventType=win32evtlog.EVENTLOG_WARNING_TYPE, strings=["A warning"], data = "Raw\0Data") ! win32evtlogutil.ReportEvent(logType, 1, eventType=win32evtlog.EVENTLOG_INFORMATION_TYPE, strings=["An info"], data = "Raw\0Data") ! print "Successfully wrote 3 records to the log" if do_read: --- 84,101 ---- verbose = verbose + 1 if do_write: ! ph=win32api.GetCurrentProcess() ! th = win32security.OpenProcessToken(ph,win32con.TOKEN_READ) ! my_sid = win32security.GetTokenInformation(th,win32security.TokenUser)[0] ! ! win32evtlogutil.ReportEvent(logType, 2, ! strings=["The message text for event 2","Another insert"], ! data = "Raw\0Data", sid = my_sid) ! win32evtlogutil.ReportEvent(logType, 1, eventType=win32evtlog.EVENTLOG_WARNING_TYPE, ! strings=["A warning","An even more dire warning"], ! data = "Raw\0Data", sid = my_sid) ! win32evtlogutil.ReportEvent(logType, 1, eventType=win32evtlog.EVENTLOG_INFORMATION_TYPE, ! strings=["An info","Too much info"], ! data = "Raw\0Data", sid = my_sid) ! print("Successfully wrote 3 records to the log") if do_read: |