|
| 1 | +/* |
| 2 | + * LocalDebugLevelStart.h |
| 3 | + * Include to propagate global debug levels to file local ones and to define appropriate print macros. |
| 4 | + * !!! If used in included (.hpp) files, #include "LocalDebugLevelEnd.h" must be used at end of file to undefine local macros. |
| 5 | + * If, for example, #define LOCAL_TRACE is placed before this include, it will not be propagated. This enables TRACE-level output to be selected only. |
| 6 | + * |
| 7 | + * LOCAL_TRACE // Information you need to understand details of a function or if you hunt a bug. |
| 8 | + * LOCAL_DEBUG // Information need to understand the operating of your program. E.g. function calls and values of control variables. |
| 9 | + * LOCAL_INFO // Information you want to see in regular operation to see what the program is doing. E.g. "Now playing Muppets melody". |
| 10 | + * LOCAL_WARN // Information that the program may encounter problems, like small Heap/Stack area. |
| 11 | + * LOCAL_ERROR // Informations to explain why the program will not run. E.g. not enough Ram for all created objects. |
| 12 | + * |
| 13 | + * Copyright (C) 2024-2026 Armin Joachimsmeyer |
| 14 | + * Email: armin.joachimsmeyer@gmail.com |
| 15 | + * |
| 16 | + * This file is part of Arduino-Utils https://github.com/ArminJo/Arduino-Utils. |
| 17 | + * |
| 18 | + * Arduino-Utils is free software: you can redistribute it and/or modify |
| 19 | + * it under the terms of the GNU General Public License as published by |
| 20 | + * the Free Software Foundation, either version 3 of the License, or |
| 21 | + * (at your option) any later version. |
| 22 | + * |
| 23 | + * This program is distributed in the hope that it will be useful, |
| 24 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 26 | + * See the GNU General Public INFOse for more details. |
| 27 | + * |
| 28 | + * You should have received a copy of the GNU General Public License |
| 29 | + * along with this program. If not, see <http://www.gnu.org/licenses/gpl.html>. |
| 30 | + * |
| 31 | + */ |
| 32 | + |
| 33 | +/////////////// put this before the include ///////////////////////// |
| 34 | +// This block must be located after the includes of other *.hpp files |
| 35 | +//#define LOCAL_INFO // This enables info output only for this file |
| 36 | +//#define LOCAL_DEBUG // This enables debug output only for this file - only for development |
| 37 | +//#define LOCAL_TRACE // This enables trace output only for this file - only for development |
| 38 | + |
| 39 | +/* |
| 40 | + * Propagate debug level to local ones but at first not to each other, i.e. enabling TRACE does not enable DEBUG and INFO |
| 41 | + */ |
| 42 | +#if defined(TRACE) // Information you need to understand details of a function or if you hunt a bug. |
| 43 | +#define LOCAL_TRACE |
| 44 | +# if !defined(DO_NOT_PROPAGATE_DEBUG_LEVELS) // Propagate levels by default i.e. enabling TRACE does enable DEBUG and INFO |
| 45 | +#define LOCAL_DEBUG |
| 46 | +#define LOCAL_INFO |
| 47 | +# endif |
| 48 | +#endif |
| 49 | + |
| 50 | +#if defined(DEBUG) // Information need to understand the operating of your program. E.g. function calls and values of control variables. |
| 51 | +#define LOCAL_DEBUG |
| 52 | +# if !defined(DO_NOT_PROPAGATE_DEBUG_LEVELS) |
| 53 | +#define LOCAL_INFO |
| 54 | +# endif |
| 55 | +#endif |
| 56 | + |
| 57 | +#if defined(INFO) // Information you want to see in regular operation to see what the program is doing. E.g. "START ../src/LightToTone.cpp Version 1.2 from Dec 31 2019" or "Now playing Muppets melody". |
| 58 | +#define LOCAL_INFO |
| 59 | +#endif |
| 60 | + |
| 61 | +/* |
| 62 | + * Define appropriate print macros |
| 63 | + */ |
| 64 | +#if defined(LOCAL_TRACE) |
| 65 | +#define TRACE_PRINT(...) Serial.print(__VA_ARGS__) |
| 66 | +#define TRACE_PRINTLN(...) Serial.println(__VA_ARGS__) |
| 67 | +#define TRACE_FLUSH() Serial.flush() |
| 68 | +#else |
| 69 | +#define TRACE_PRINT(...) void() |
| 70 | +#define TRACE_PRINTLN(...) void() |
| 71 | +#define TRACE_FLUSH() void() |
| 72 | +#endif |
| 73 | + |
| 74 | +#if defined(LOCAL_DEBUG) |
| 75 | +#define DEBUG_PRINT(...) Serial.print(__VA_ARGS__) |
| 76 | +#define DEBUG_PRINTLN(...) Serial.println(__VA_ARGS__) |
| 77 | +#define DEBUG_FLUSH() Serial.flush() |
| 78 | +#else |
| 79 | +#define DEBUG_PRINT(...) void() |
| 80 | +#define DEBUG_PRINTLN(...) void() |
| 81 | +#define DEBUG_FLUSH() void() |
| 82 | + |
| 83 | +#endif |
| 84 | + |
| 85 | +#if defined(LOCAL_INFO) |
| 86 | +#define INFO_PRINT(...) Serial.print(__VA_ARGS__) |
| 87 | +#define INFO_PRINTLN(...) Serial.println(__VA_ARGS__) |
| 88 | +#define INFO_FLUSH() Serial.flush() |
| 89 | +#else |
| 90 | +#define INFO_PRINT(...) void() |
| 91 | +#define INFO_PRINTLN(...) void() |
| 92 | +#define INFO_FLUSH() void() |
| 93 | +#endif |
| 94 | + |
0 commit comments