1 /* 2 * Copyright (c) 2008-2013 Travis Geiselbrecht 3 * 4 * Use of this source code is governed by a MIT-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/MIT 7 */ 8 #pragma once 9 10 #include <stdio.h> 11 12 /* trace routines */ 13 #define TRACE_ENTRY printf("%s: entry\n", __PRETTY_FUNCTION__) 14 #define TRACE_EXIT printf("%s: exit\n", __PRETTY_FUNCTION__) 15 #define TRACE_ENTRY_OBJ printf("%s: entry obj %p\n", __PRETTY_FUNCTION__, this) 16 #define TRACE_EXIT_OBJ printf("%s: exit obj %p\n", __PRETTY_FUNCTION__, this) 17 #define TRACE printf("%s:%d\n", __PRETTY_FUNCTION__, __LINE__) 18 #define TRACEF(str, x...) do { printf("%s:%d: " str, __PRETTY_FUNCTION__, __LINE__, ## x); } while (0) 19 20 /* trace routines that work if LOCAL_TRACE is set */ 21 #define LTRACE_ENTRY do { if (LOCAL_TRACE) { TRACE_ENTRY; } } while (0) 22 #define LTRACE_EXIT do { if (LOCAL_TRACE) { TRACE_EXIT; } } while (0) 23 #define LTRACE do { if (LOCAL_TRACE) { TRACE; } } while (0) 24 #define LTRACEF(x...) do { if (LOCAL_TRACE) { TRACEF(x); } } while (0) 25 #define LTRACEF_LEVEL(level, x...) do { if (LOCAL_TRACE >= (level)) { TRACEF(x); } } while (0) 26