Skip to content

Commit

Permalink
Runs on non-win32 systems now, without producing any output.
Browse files Browse the repository at this point in the history
  • Loading branch information
dougransom committed Feb 23, 2024
1 parent dba7511 commit 1820edd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# pydbugstring

Provides a function to call Windows OutputDebugString with any Python Object.
Provides a handler for the Python Logging Module which sends logging to OutputDebugString.
Provides a function OutputDebugString to call:
- on win32 platforms, calls the ctypes.windll.kernel32.OutputDebugStringW with any Python Object, after converting that object to a string.
- on other platforms, converts the argument to a string and discards it, returns 0

Provides a handler for the Python Logging Module which sends logging to OutputDebugString. On platforms other than win32, the logging output is disccarded.


The output can be viewed using the [DebugView](https://learn.microsoft.com/en-us/sysinternals/downloads/debugview) program from the SysInternals package from Microsoft.
Expand Down
2 changes: 1 addition & 1 deletion src/pydebugstring/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"function to write python obects to OutputDebugString on windows"
__version__ = '1.0.0.1'
__version__ = '1.0.0.2'
from .output import outputDebugString
from .outputdebugstringhandler import OutputDebugStringHandler
10 changes: 9 additions & 1 deletion src/pydebugstring/output.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import ctypes
W32OutputDebugString = ctypes.windll.kernel32.OutputDebugStringW
from sys import platform
if platform == "win32":
W32OutputDebugString = ctypes.windll.kernel32.OutputDebugStringW
else:
def W32OutputDebugString(arg):
"""Dummy function as an alternative to W32OutputDebugString in case code using this module
is run on platfomrs other than win32. W32OutputDebugString does nothing, returns 0.
"""
return 0

def outputDebugString(to_show):
"""
Expand Down

0 comments on commit 1820edd

Please sign in to comment.