-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
4 changed files
with
124 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (C) 2024 Joshua DeWeese <josh.deweese@gmail.com> | ||
* | ||
* 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 <josh.deweese@gmail.com> | ||
* | ||
*/ | ||
|
||
#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 */ | ||
/** @} */ |
45 changes: 45 additions & 0 deletions
45
pkg/littlefs/patches/0001-remove-pkg-supplied-logging-macros.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
From 0a1aaadaa6c2e58c7c7e60d28130b77d0e9ac382 Mon Sep 17 00:00:00 2001 | ||
From: Joshua DeWeese <jdeweese@primecontrols.com> | ||
Date: Mon, 7 Oct 2024 12:20:59 -0400 | ||
Subject: [PATCH] remove pkg supplied logging macros | ||
|
||
--- | ||
lfs_util.h | 22 ---------------------- | ||
1 file changed, 22 deletions(-) | ||
|
||
diff --git a/lfs_util.h b/lfs_util.h | ||
index b2dc237..fcc4a00 100644 | ||
--- a/lfs_util.h | ||
+++ b/lfs_util.h | ||
@@ -44,28 +44,6 @@ extern "C" | ||
// macros must not have side-effects as the macros can be removed for a smaller | ||
// code footprint | ||
|
||
-// Logging functions | ||
-#ifndef LFS_NO_DEBUG | ||
-#define LFS_DEBUG(fmt, ...) \ | ||
- printf("lfs debug:%d: " fmt "\n", __LINE__, __VA_ARGS__) | ||
-#else | ||
-#define LFS_DEBUG(fmt, ...) | ||
-#endif | ||
- | ||
-#ifndef LFS_NO_WARN | ||
-#define LFS_WARN(fmt, ...) \ | ||
- printf("lfs warn:%d: " fmt "\n", __LINE__, __VA_ARGS__) | ||
-#else | ||
-#define LFS_WARN(fmt, ...) | ||
-#endif | ||
- | ||
-#ifndef LFS_NO_ERROR | ||
-#define LFS_ERROR(fmt, ...) \ | ||
- printf("lfs error:%d: " fmt "\n", __LINE__, __VA_ARGS__) | ||
-#else | ||
-#define LFS_ERROR(fmt, ...) | ||
-#endif | ||
- | ||
// Runtime assertions | ||
#ifndef LFS_NO_ASSERT | ||
#define LFS_ASSERT(test) assert(test) | ||
-- | ||
2.34.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters