From 96e5f141acf46ea9c457a860d79241970886b47f Mon Sep 17 00:00:00 2001 From: Joshua DeWeese Date: Mon, 7 Oct 2024 12:55:28 -0400 Subject: [PATCH] pkg/littlefs: make use of RIOT's logging This patch replaces the package supplied logging macros with RIOT's. It also removes the requirement that DEVELHELP be defined to enable logging. Instead, logging can be enabled/dissabled via the log level. --- pkg/littlefs/Makefile | 6 +- pkg/littlefs/lfs_log.h | 74 ++++++++++++++++++ ...1-remove-pkg-supplied-logging-macros.patch | Bin 0 -> 1120 bytes tests/pkg/littlefs/Makefile | 3 + 4 files changed, 79 insertions(+), 4 deletions(-) create mode 100644 pkg/littlefs/lfs_log.h create mode 100644 pkg/littlefs/patches/0001-remove-pkg-supplied-logging-macros.patch diff --git a/pkg/littlefs/Makefile b/pkg/littlefs/Makefile index 99d650946a..9ea4e6015a 100644 --- a/pkg/littlefs/Makefile +++ b/pkg/littlefs/Makefile @@ -8,10 +8,8 @@ include $(RIOTBASE)/pkg/pkg.mk CFLAGS += -Wno-format -# Disable debug printing -ifneq ($(DEVELHELP),1) - CFLAGS += -DLFS_NO_DEBUG -DLFS_NO_WARN -DLFS_NO_ERROR -endif +# replace pkg supplied logging macros with RIOT's +CFLAGS += -include $(PKG_DIR)/lfs_log.h all: $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR) -f $(RIOTBASE)/Makefile.base diff --git a/pkg/littlefs/lfs_log.h b/pkg/littlefs/lfs_log.h new file mode 100644 index 0000000000..0ffe264cf6 --- /dev/null +++ b/pkg/littlefs/lfs_log.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2024 Joshua DeWeese + * + * This file is subject to the terms and conditions of the GNU Lesser General + * Public License v2.1. See the file LICENSE in the top level directory for more + * details. + */ + +/** + * @ingroup sys_littlefs + * @{ + * + * @file + * @brief littlefs logging macro overrides + * + * This header provides re-implementations of the logging and debugging macros + * used in littlefs. This is to allow the package to make use of RIOT's own + * modules for logging and debugging. + * + * @author Joshua DeWeese + * + */ + +#ifndef LFS_LOG_H +#define LFS_LOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "log.h" + +/** + * @brief Private macro for routing littlefs log msgs to RIOT's log module. + * + * @param[in] level log level of this log message + * @param[in] fmt printf style format string + * @param[inout] ... printf style variadic args + */ +#define _LFS_LOG(level, fmt, ...)\ + LOG(level, "lfs: " fmt "%s\n", __VA_ARGS__) + +/** */ +/** + * @name littlefs overrides + * @{ + * @brief Re-implementation of littlefs's logging and debugging macros. + */ + +/** override of littlefs's `LFS_DEBUG()` */ +#ifndef LFS_NO_DEBUG +# define LFS_DEBUG(...) _LFS_LOG(LOG_DEBUG, __VA_ARGS__, "") +#else +# define LFS_DEBUG(...) +#endif + +/** override of littlefs's `LFS_WARN()` */ +#ifndef LFS_NO_WARN +# define LFS_WARN(...) _LFS_LOG(LOG_WARNING, __VA_ARGS__, "") +#else +# define LFS_WARN(...) +#endif + +/** override of littlefs's `LFS_ERROR()` */ +#ifndef LFS_NO_ERROR +# define LFS_ERROR(...) _LFS_LOG(LOG_ERROR, __VA_ARGS__, "") +#else +# define LFS_ERROR(...) +#endif + +/** @} */ + +#endif /* LFS_LOG_H */ +/** @} */ diff --git a/pkg/littlefs/patches/0001-remove-pkg-supplied-logging-macros.patch b/pkg/littlefs/patches/0001-remove-pkg-supplied-logging-macros.patch new file mode 100644 index 0000000000000000000000000000000000000000..cc806cb83f662098404686297eb6532b0dd2a721 GIT binary patch literal 1120 zcmbtT(Q4Z;6n)oM95Mz8iCx)olhlmStWCR(t{qOdKCHti@^#|QmVza(eb~oOPBTc# z$V-L6SBHDgJvvvqsC5M{0wF{u#7Ks8JdtBLrV-D=NigJ#@i^mjBIIxq;)_<8(;C4T zoX49FA?E?Ra5OPKYqM$u&gqWG5Z*mx^w>tH>$<2&YGrF(8ei(_Jv$ec;+AlLF>a)F zJYj?&j6)tDpTOf0=WO0A9!T04KfX?H&p!S{O_lylSpQnWH0yO)P=-=3mxWrQ60+8Y zG0*cD%G{)lElPidKL|rO@IQ+oKwgvtxe{tg*`Q6$s3coxWx8IEv8>2*SG_DO#L*7x zVrRn&mC+LxVJ5@j*!OcOBf&WW&PP$y3fik>{eB;N^{1!sqG%9K(09KP+@78+)e4=n z4#UyW_Hd{gW1+OgN;n%#k&#Dv?kqA826jdN5~WaB(AKXExvn8#Dp8hHZwRH%$idpW z*(l4vJlExFYh~Ujxv_wGZ;IRz=2( oK!)n)spEyI)A@Xs+%oKr{Tb_8GPbv^ecrhH4i@^u$PXC%3ljlKC;$Ke literal 0 HcmV?d00001 diff --git a/tests/pkg/littlefs/Makefile b/tests/pkg/littlefs/Makefile index 4b57fbea26..7b977c1d23 100644 --- a/tests/pkg/littlefs/Makefile +++ b/tests/pkg/littlefs/Makefile @@ -4,4 +4,7 @@ USEMODULE += littlefs USEMODULE += embunit USEMODULE += mtd_emulated +# silence expected errors +CFLAGS += -DLOG_LEVEL=LOG_NONE + include $(RIOTBASE)/Makefile.include