gh-135852: Remove out of tree pywin32 dependency for NTEventLogHandler#137860
gh-135852: Remove out of tree pywin32 dependency for NTEventLogHandler#137860serhiy-storchaka merged 29 commits intopython:mainfrom
Conversation
sharktide
left a comment
There was a problem hiding this comment.
Please fix the test fails :)
|
Sorry, I forgot to check the CI result after the push. |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Thank you for your PR @aisk. It look interesting.
Could you please show how can this be used in NTEventLogHandler? Maybe not in this PR, but in a separate PR created on top of this?
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Thanks for the view! I'll create another PR based on this to try to implement the whole feature in the original issue. |
|
@serhiy-storchaka Hi, I found that using this in |
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Very well. I have some nitpicks and questions, but mostly LGTM.
NTEventLogHandler only uses a single-string list and don't use a raw_data. Removing these features would simplify the code. But it is fine to keep them for future.
|
Hi, thank you for the review! I changed to just to support a single string as event log message to reduce the complexity, and now the codes are ready for review. |
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
Thank you for your contribution, @aisk. 🎄 |
|
…Handler (pythonGH-137860) Add RegisterEventSource(), DeregisterEventSource(), ReportEvent() and a number of EVENTLOG_* constants to _winapi.
Please note that the
lpUserSidparameter in ReportEvent don't added because it needs passing a new struct from Python to it, and we don't need this parameter for the usage of implementNTEventLogHandler. If we want add it in the future, we can add it as kwargs.Docuements for these functions:
For the
NTEventLogHandler, there is a implementation detail:The old implementation based on
pywin32, ifdllnameis not specified,pywin32will using a vendored dll in that package, as a log template for the NT event log system.For the new implement in this PR, if the
dllnameis not specified, I decided not to register the dll. As a result, the log still can be send to the NT Event Log System, we can see it in the Event Viewer.But the event will show some thing like this (I just use a picture from the Internet because I'm using a localized Windows which the text is Chinese but they are the same thing):
And I think it's OK because we can check the Detail tab to see the original message, for develop purpose this is enough. For users with production usage, they can provide their own dlls as the message template.
logging.handlers.NTEventLogHandler#135852