Fix: python agent: 'time' has no attribute 'clock'
[lttng-ust.git] / python-lttngust / lttngust / debug.py
CommitLineData
de4dee04
PP
1# -*- coding: utf-8 -*-
2#
3# Copyright (C) 2015 - Philippe Proulx <pproulx@efficios.com>
4#
5# This library is free software; you can redistribute it and/or modify it under
6# the terms of the GNU Lesser General Public License as published by the Free
7# Software Foundation; version 2.1 of the License.
8#
9# This library is distributed in the hope that it will be useful, but WITHOUT
10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12# details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this library; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
18from __future__ import unicode_literals, print_function
e7bf4968 19import lttngust.compat
de4dee04
PP
20import time
21import sys
22import os
23
24
25_ENABLE_DEBUG = os.getenv('LTTNG_UST_PYTHON_DEBUG', '0') == '1'
26
27
28if _ENABLE_DEBUG:
29 import inspect
30
31 def _pwarning(msg):
32 fname = inspect.stack()[1][3]
33 fmt = '[{:.6f}] LTTng-UST warning: {}(): {}'
e7bf4968 34 print(fmt.format(lttngust.compat._clock(), fname, msg), file=sys.stderr)
de4dee04
PP
35
36 def _pdebug(msg):
37 fname = inspect.stack()[1][3]
38 fmt = '[{:.6f}] LTTng-UST debug: {}(): {}'
e7bf4968 39 print(fmt.format(lttngust.compat._clock(), fname, msg), file=sys.stderr)
de4dee04
PP
40
41 _pdebug('debug is enabled')
42else:
43 def _pwarning(msg):
44 pass
45
46 def _pdebug(msg):
47 pass
This page took 0.025236 seconds and 4 git commands to generate.