Move all sources to 'src/'
[lttng-ust.git] / src / python-lttngust / lttngust / debug.py
diff --git a/src/python-lttngust/lttngust/debug.py b/src/python-lttngust/lttngust/debug.py
new file mode 100644 (file)
index 0000000..59aeb79
--- /dev/null
@@ -0,0 +1,36 @@
+# -*- coding: utf-8 -*-
+#
+# SPDX-License-Identifier: LGPL-2.1-only
+#
+# Copyright (C) 2015 Philippe Proulx <pproulx@efficios.com>
+
+from __future__ import unicode_literals, print_function
+import lttngust.compat
+import time
+import sys
+import os
+
+
+_ENABLE_DEBUG = os.getenv('LTTNG_UST_PYTHON_DEBUG', '0') == '1'
+
+
+if _ENABLE_DEBUG:
+    import inspect
+
+    def _pwarning(msg):
+        fname = inspect.stack()[1][3]
+        fmt = '[{:.6f}] LTTng-UST warning: {}(): {}'
+        print(fmt.format(lttngust.compat._clock(), fname, msg), file=sys.stderr)
+
+    def _pdebug(msg):
+        fname = inspect.stack()[1][3]
+        fmt = '[{:.6f}] LTTng-UST debug: {}(): {}'
+        print(fmt.format(lttngust.compat._clock(), fname, msg), file=sys.stderr)
+
+    _pdebug('debug is enabled')
+else:
+    def _pwarning(msg):
+        pass
+
+    def _pdebug(msg):
+        pass
This page took 0.02401 seconds and 4 git commands to generate.