MLIB
Loading...
Searching...
No Matches
trace.h
Go to the documentation of this file.
1/*
2 Copyright (c) Mircea Neacsu (2014-2025) Licensed under MIT License.
3 This is part of MLIB project. See LICENSE file for full license terms.
4*/
5
6#pragma once
7
8#if __has_include("defs.h")
9#include "defs.h"
10#endif
11
12#include "dprintf.h"
13
14#undef TRACE
15#undef TRACE1
16#undef TRACE2
17#undef TRACE3
18#undef TRACE4
19#undef TRACE5
20#undef TRACE6
21#undef TRACE7
22#undef TRACE8
23#undef TRACE9
24
42
44// MLIB_SYSLOG_TRACE forces MLIB_TRACE
45#if MLIB_SYSLOG_TRACE && !defined(MLIB_TRACE)
46#define MLIB_TRACE MLIB_SYSLOG_TRACE
47#endif
48
49// _TRACE forces MLIB_TRACE
50#if defined(_TRACE) && !defined(MLIB_TRACE)
51#define MLIB_TRACE _TRACE
52#endif
53
54#if defined(MLIB_TRACE_LEVEL)
55// only some traces enabled (up to and including MLIB_TRACE_LEVEL)
56#define __TRL(A) (A > MLIB_TRACE_LEVEL) ? 0 : TRACE
57#define TRACE1 __TRL (1)
58#define TRACE2 __TRL (2)
59#define TRACE3 __TRL (3)
60#define TRACE4 __TRL (4)
61#define TRACE5 __TRL (5)
62#define TRACE6 __TRL (6)
63#define TRACE7 __TRL (7)
64#define TRACE8 __TRL (8)
65#define TRACE9 __TRL (9)
66#else
67// all traces are enabled
68#define TRACE1 TRACE
69#define TRACE2 TRACE
70#define TRACE3 TRACE
71#define TRACE4 TRACE
72#define TRACE5 TRACE
73#define TRACE6 TRACE
74#define TRACE7 TRACE
75#define TRACE8 TRACE
76#define TRACE9 TRACE
77#endif
78
79#ifdef MLIB_TRACE
80#if MLIB_SYSLOG_TRACE
81#include "log.h"
82#define TRACE syslog_debug
83#else
84#define TRACE dprintf
85#endif
86#else
87#define TRACE 1 ? 0 : dprintf
88#endif
Definition of dprintf () function.
syslog related functions.