diff options
author | Christopher Haster <chaster@utexas.edu> | 2019-05-31 12:40:19 +0300 |
---|---|---|
committer | Christopher Haster <chaster@utexas.edu> | 2019-07-16 23:14:32 +0300 |
commit | 6a1ee914904707cb65af5d9a9412cf6139c08b78 (patch) | |
tree | 06dbe06a2ec0290af49efe294bfb75247a5451f4 /lfs_util.h | |
parent | abd90cb84c818a663b584575b019258d01d0065e (diff) |
Added trace statements through LFS_YES_TRACE
To use, compile and run with LFS_YES_TRACE defined:
make CFLAGS+=-DLFS_YES_TRACE=1 test_format
The name LFS_YES_TRACE was chosen to match the LFS_NO_DEBUG and
LFS_NO_WARN defines for the similar levels of output. The YES is
necessary to avoid a conflict with the actual LFS_TRACE macro that
gets emitting. LFS_TRACE can also be defined directly to provide
a custom trace formatter.
Hopefully having trace statements at the littlefs C API helps
debugging and reproducing issues.
Diffstat (limited to 'lfs_util.h')
-rw-r--r-- | lfs_util.h | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -31,7 +31,10 @@ #ifndef LFS_NO_ASSERT #include <assert.h> #endif -#if !defined(LFS_NO_DEBUG) || !defined(LFS_NO_WARN) || !defined(LFS_NO_ERROR) +#if !defined(LFS_NO_DEBUG) || \ + !defined(LFS_NO_WARN) || \ + !defined(LFS_NO_ERROR) || \ + defined(LFS_YES_TRACE) #include <stdio.h> #endif @@ -46,6 +49,13 @@ extern "C" // code footprint // Logging functions +#ifdef LFS_YES_TRACE +#define LFS_TRACE(fmt, ...) \ + printf("lfs trace:%d: " fmt "\n", __LINE__, __VA_ARGS__) +#else +#define LFS_TRACE(fmt, ...) +#endif + #ifndef LFS_NO_DEBUG #define LFS_DEBUG(fmt, ...) \ printf("lfs debug:%d: " fmt "\n", __LINE__, __VA_ARGS__) |