| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <link rel="STYLESHEET" href="lib.css" type='text/css' /> |
| 5 | <link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" /> |
| 6 | <link rel='start' href='../index.html' title='Python Documentation Index' /> |
| 7 | <link rel="first" href="lib.html" title='Python Library Reference' /> |
| 8 | <link rel='contents' href='contents.html' title="Contents" /> |
| 9 | <link rel='index' href='genindex.html' title='Index' /> |
| 10 | <link rel='last' href='about.html' title='About this document...' /> |
| 11 | <link rel='help' href='about.html' title='About this document...' /> |
| 12 | <link rel="next" href="node354.html" /> |
| 13 | <link rel="prev" href="node352.html" /> |
| 14 | <link rel="parent" href="node345.html" /> |
| 15 | <link rel="next" href="node354.html" /> |
| 16 | <meta name='aesop' content='information' /> |
| 17 | <title>6.29.5.8 NTEventLogHandler</title> |
| 18 | </head> |
| 19 | <body> |
| 20 | <DIV CLASS="navigation"> |
| 21 | <div id='top-navigation-panel' xml:id='top-navigation-panel'> |
| 22 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 23 | <tr> |
| 24 | <td class='online-navigation'><a rel="prev" title="6.29.5.7 SysLogHandler" |
| 25 | href="node352.html"><img src='../icons/previous.png' |
| 26 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 27 | <td class='online-navigation'><a rel="parent" title="6.29.5 Handler Objects" |
| 28 | href="node345.html"><img src='../icons/up.png' |
| 29 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 30 | <td class='online-navigation'><a rel="next" title="6.29.5.9 SMTPHandler" |
| 31 | href="node354.html"><img src='../icons/next.png' |
| 32 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 33 | <td align="center" width="100%">Python Library Reference</td> |
| 34 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 35 | href="contents.html"><img src='../icons/contents.png' |
| 36 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 37 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 38 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 39 | <td class='online-navigation'><a rel="index" title="Index" |
| 40 | href="genindex.html"><img src='../icons/index.png' |
| 41 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 42 | </tr></table> |
| 43 | <div class='online-navigation'> |
| 44 | <b class="navlabel">Previous:</b> |
| 45 | <a class="sectref" rel="prev" href="node352.html">6.29.5.7 SysLogHandler</A> |
| 46 | <b class="navlabel">Up:</b> |
| 47 | <a class="sectref" rel="parent" href="node345.html">6.29.5 Handler Objects</A> |
| 48 | <b class="navlabel">Next:</b> |
| 49 | <a class="sectref" rel="next" href="node354.html">6.29.5.9 SMTPHandler</A> |
| 50 | </div> |
| 51 | <hr /></div> |
| 52 | </DIV> |
| 53 | <!--End of Navigation Panel--> |
| 54 | |
| 55 | <H3><A NAME="SECTION0082958000000000000000"> |
| 56 | 6.29.5.8 NTEventLogHandler</A> |
| 57 | </H3> |
| 58 | |
| 59 | <P> |
| 60 | The <tt class="class">NTEventLogHandler</tt> class supports sending logging messages |
| 61 | to a local Windows NT, Windows 2000 or Windows XP event log. Before |
| 62 | you can use it, you need Mark Hammond's Win32 extensions for Python |
| 63 | installed. |
| 64 | |
| 65 | <P> |
| 66 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 67 | <td><nobr><b><span class="typelabel">class</span> <tt id='l2h-2535' xml:id='l2h-2535' class="class">NTEventLogHandler</tt></b>(</nobr></td> |
| 68 | <td><var>appname</var><big>[</big><var>, |
| 69 | dllname</var><big>[</big><var>, logtype</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt> |
| 70 | <dd> |
| 71 | Returns a new instance of the <tt class="class">NTEventLogHandler</tt> class. The |
| 72 | <var>appname</var> is used to define the application name as it appears in the |
| 73 | event log. An appropriate registry entry is created using this name. |
| 74 | The <var>dllname</var> should give the fully qualified pathname of a .dll or .exe |
| 75 | which contains message definitions to hold in the log (if not specified, |
| 76 | <code>'win32service.pyd'</code> is used - this is installed with the Win32 |
| 77 | extensions and contains some basic placeholder message definitions. |
| 78 | Note that use of these placeholders will make your event logs big, as the |
| 79 | entire message source is held in the log. If you want slimmer logs, you have |
| 80 | to pass in the name of your own .dll or .exe which contains the message |
| 81 | definitions you want to use in the event log). The <var>logtype</var> is one of |
| 82 | <code>'Application'</code>, <code>'System'</code> or <code>'Security'</code>, and |
| 83 | defaults to <code>'Application'</code>. |
| 84 | </dl> |
| 85 | |
| 86 | <P> |
| 87 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 88 | <td><nobr><b><tt id='l2h-2536' xml:id='l2h-2536' class="method">close</tt></b>(</nobr></td> |
| 89 | <td><var></var>)</td></tr></table></dt> |
| 90 | <dd> |
| 91 | At this point, you can remove the application name from the registry as a |
| 92 | source of event log entries. However, if you do this, you will not be able |
| 93 | to see the events as you intended in the Event Log Viewer - it needs to be |
| 94 | able to access the registry to get the .dll name. The current version does |
| 95 | not do this (in fact it doesn't do anything). |
| 96 | </dl> |
| 97 | |
| 98 | <P> |
| 99 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 100 | <td><nobr><b><tt id='l2h-2537' xml:id='l2h-2537' class="method">emit</tt></b>(</nobr></td> |
| 101 | <td><var>record</var>)</td></tr></table></dt> |
| 102 | <dd> |
| 103 | Determines the message ID, event category and event type, and then logs the |
| 104 | message in the NT event log. |
| 105 | </dl> |
| 106 | |
| 107 | <P> |
| 108 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 109 | <td><nobr><b><tt id='l2h-2538' xml:id='l2h-2538' class="method">getEventCategory</tt></b>(</nobr></td> |
| 110 | <td><var>record</var>)</td></tr></table></dt> |
| 111 | <dd> |
| 112 | Returns the event category for the record. Override this if you |
| 113 | want to specify your own categories. This version returns 0. |
| 114 | </dl> |
| 115 | |
| 116 | <P> |
| 117 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 118 | <td><nobr><b><tt id='l2h-2539' xml:id='l2h-2539' class="method">getEventType</tt></b>(</nobr></td> |
| 119 | <td><var>record</var>)</td></tr></table></dt> |
| 120 | <dd> |
| 121 | Returns the event type for the record. Override this if you want |
| 122 | to specify your own types. This version does a mapping using the |
| 123 | handler's typemap attribute, which is set up in <tt class="method">__init__()</tt> |
| 124 | to a dictionary which contains mappings for <tt class="constant">DEBUG</tt>, |
| 125 | <tt class="constant">INFO</tt>, <tt class="constant">WARNING</tt>, <tt class="constant">ERROR</tt> and |
| 126 | <tt class="constant">CRITICAL</tt>. If you are using your own levels, you will either need |
| 127 | to override this method or place a suitable dictionary in the |
| 128 | handler's <var>typemap</var> attribute. |
| 129 | </dl> |
| 130 | |
| 131 | <P> |
| 132 | <dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"> |
| 133 | <td><nobr><b><tt id='l2h-2540' xml:id='l2h-2540' class="method">getMessageID</tt></b>(</nobr></td> |
| 134 | <td><var>record</var>)</td></tr></table></dt> |
| 135 | <dd> |
| 136 | Returns the message ID for the record. If you are using your |
| 137 | own messages, you could do this by having the <var>msg</var> passed to the |
| 138 | logger being an ID rather than a format string. Then, in here, |
| 139 | you could use a dictionary lookup to get the message ID. This |
| 140 | version returns 1, which is the base message ID in |
| 141 | <span class="file">win32service.pyd</span>. |
| 142 | </dl> |
| 143 | |
| 144 | <P> |
| 145 | |
| 146 | <DIV CLASS="navigation"> |
| 147 | <div class='online-navigation'> |
| 148 | <p></p><hr /> |
| 149 | <table align="center" width="100%" cellpadding="0" cellspacing="2"> |
| 150 | <tr> |
| 151 | <td class='online-navigation'><a rel="prev" title="6.29.5.7 SysLogHandler" |
| 152 | href="node352.html"><img src='../icons/previous.png' |
| 153 | border='0' height='32' alt='Previous Page' width='32' /></A></td> |
| 154 | <td class='online-navigation'><a rel="parent" title="6.29.5 Handler Objects" |
| 155 | href="node345.html"><img src='../icons/up.png' |
| 156 | border='0' height='32' alt='Up One Level' width='32' /></A></td> |
| 157 | <td class='online-navigation'><a rel="next" title="6.29.5.9 SMTPHandler" |
| 158 | href="node354.html"><img src='../icons/next.png' |
| 159 | border='0' height='32' alt='Next Page' width='32' /></A></td> |
| 160 | <td align="center" width="100%">Python Library Reference</td> |
| 161 | <td class='online-navigation'><a rel="contents" title="Table of Contents" |
| 162 | href="contents.html"><img src='../icons/contents.png' |
| 163 | border='0' height='32' alt='Contents' width='32' /></A></td> |
| 164 | <td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png' |
| 165 | border='0' height='32' alt='Module Index' width='32' /></a></td> |
| 166 | <td class='online-navigation'><a rel="index" title="Index" |
| 167 | href="genindex.html"><img src='../icons/index.png' |
| 168 | border='0' height='32' alt='Index' width='32' /></A></td> |
| 169 | </tr></table> |
| 170 | <div class='online-navigation'> |
| 171 | <b class="navlabel">Previous:</b> |
| 172 | <a class="sectref" rel="prev" href="node352.html">6.29.5.7 SysLogHandler</A> |
| 173 | <b class="navlabel">Up:</b> |
| 174 | <a class="sectref" rel="parent" href="node345.html">6.29.5 Handler Objects</A> |
| 175 | <b class="navlabel">Next:</b> |
| 176 | <a class="sectref" rel="next" href="node354.html">6.29.5.9 SMTPHandler</A> |
| 177 | </div> |
| 178 | </div> |
| 179 | <hr /> |
| 180 | <span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span> |
| 181 | </DIV> |
| 182 | <!--End of Navigation Panel--> |
| 183 | <ADDRESS> |
| 184 | See <i><a href="about.html">About this document...</a></i> for information on suggesting changes. |
| 185 | </ADDRESS> |
| 186 | </BODY> |
| 187 | </HTML> |