summaryrefslogtreecommitdiff
path: root/psutil/_common.py
diff options
context:
space:
mode:
Diffstat (limited to 'psutil/_common.py')
-rw-r--r--psutil/_common.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/psutil/_common.py b/psutil/_common.py
index 729b1983..453c771d 100644
--- a/psutil/_common.py
+++ b/psutil/_common.py
@@ -7,7 +7,7 @@
# Note: this module is imported by setup.py so it should not import
# psutil or third-party modules.
-from __future__ import division
+from __future__ import division, print_function
import contextlib
import errno
@@ -66,7 +66,7 @@ __all__ = [
'conn_tmap', 'deprecated_method', 'isfile_strict', 'memoize',
'parse_environ_block', 'path_exists_strict', 'usage_percent',
'supports_ipv6', 'sockfam_to_enum', 'socktype_to_enum', "wrap_numbers",
- 'bytes2human', 'conn_to_ntuple', 'hilite',
+ 'bytes2human', 'conn_to_ntuple', 'hilite', 'debug',
]
@@ -787,3 +787,11 @@ def hilite(s, ok=True, bold=False):
if bold:
attr.append('1')
return '\x1b[%sm%s\x1b[0m' % (';'.join(attr), s)
+
+
+if bool(os.getenv('PSUTIL_DEBUG', 0)):
+ def debug(msg):
+ print("psutil-debug> " + msg, file=sys.stderr)
+else:
+ def debug(msg):
+ pass