diff options
-rw-r--r-- | psutil/_psutil_common.c | 16 | ||||
-rw-r--r-- | psutil/_psutil_common.h | 10 |
2 files changed, 9 insertions, 17 deletions
diff --git a/psutil/_psutil_common.c b/psutil/_psutil_common.c index ff060a51..ddb994dc 100644 --- a/psutil/_psutil_common.c +++ b/psutil/_psutil_common.c @@ -150,22 +150,6 @@ psutil_set_testing(PyObject *self, PyObject *args) { /* - * Print a debug message on stderr. No-op if PSUTIL_DEBUG env var is not set. - */ -void -psutil_debug(const char* format, ...) { - va_list argptr; - if (PSUTIL_DEBUG) { - va_start(argptr, format); - fprintf(stderr, "psutil-debug> "); - vfprintf(stderr, format, argptr); - fprintf(stderr, "\n"); - va_end(argptr); - } -} - - -/* * Called on module import on all platforms. */ int diff --git a/psutil/_psutil_common.h b/psutil/_psutil_common.h index cb0b399d..d8b691d4 100644 --- a/psutil/_psutil_common.h +++ b/psutil/_psutil_common.h @@ -101,9 +101,17 @@ PyObject* PyErr_SetFromOSErrnoWithSyscall(const char *syscall); // ==================================================================== PyObject* psutil_set_testing(PyObject *self, PyObject *args); -void psutil_debug(const char* format, ...); int psutil_setup(void); + +// Print a debug message on stderr. + +#define psutil_debug(...) do { \ + fprintf(stderr, "psutil-debug [%s:%d]> ", __FILE__, __LINE__); \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\n");} while(0) + + // ==================================================================== // --- BSD // ==================================================================== |