Commit 2a33aa26 authored by Fabio Utzig's avatar Fabio Utzig Committed by Fabio Utzig
Browse files

Add logging support for Mynewt

Signed-off-by: default avatarFabio Utzig <utzig@apache.org>
parent 67716014
Loading
Loading
Loading
Loading
+53
Changes for boot/bootutil/include/bootutil/bootutil_log.h: 53 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -130,6 +130,59 @@ int sim_log_enabled(int level);
#define BOOT_LOG_DBG(...) IGNORE(__VA_ARGS__)
#endif

/*
 * When built on Mynewt, just use printf().
 */
#elif defined(MCUBOOT_MYNEWT)

#include <stdio.h>

#define BOOT_LOG_LEVEL_OFF      0
#define BOOT_LOG_LEVEL_ERROR    1
#define BOOT_LOG_LEVEL_WARNING  2
#define BOOT_LOG_LEVEL_INFO     3
#define BOOT_LOG_LEVEL_DEBUG    4

#ifndef BOOT_LOG_LEVEL
#define BOOT_LOG_LEVEL BOOT_LOG_LEVEL_INFO
#endif

#if BOOT_LOG_LEVEL >= BOOT_LOG_LEVEL_ERROR
#define BOOT_LOG_ERR(_fmt, ...)                                         \
    do {                                                                \
        printf("[ERR] " _fmt "\n", ##__VA_ARGS__);                      \
    } while (0)
#else
#define BOOT_LOG_ERR(...) IGNORE(__VA_ARGS__)
#endif

#if BOOT_LOG_LEVEL >= BOOT_LOG_LEVEL_WARNING
#define BOOT_LOG_WRN(_fmt, ...)                                         \
    do {                                                                \
        printf("[WRN] " _fmt "\n", ##__VA_ARGS__);                      \
    } while (0)
#else
#define BOOT_LOG_WRN(...) IGNORE(__VA_ARGS__)
#endif

#if BOOT_LOG_LEVEL >= BOOT_LOG_LEVEL_INFO
#define BOOT_LOG_INF(_fmt, ...)                                         \
    do {                                                                \
        printf("[INF] " _fmt "\n", ##__VA_ARGS__);                      \
    } while (0)
#else
#define BOOT_LOG_INF(...) IGNORE(__VA_ARGS__)
#endif

#if BOOT_LOG_LEVEL >= BOOT_LOG_LEVEL_DEBUG
#define BOOT_LOG_DBG(_fmt, ...)                                         \
    do {                                                                \
        printf("[DBG] " _fmt "\n", ##__VA_ARGS__);                      \
    } while (0)
#else
#define BOOT_LOG_DBG(...) IGNORE(__VA_ARGS__)
#endif

/*
 * In other environments, logging calls are no-ops.
 */