Skip to content

Commit

Permalink
feat: adding bits of logging emulation
Browse files Browse the repository at this point in the history
  • Loading branch information
malachib committed Dec 8, 2024
1 parent 1df0c96 commit 96c3e64
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/estd/port/esp-idf/fake/esp_err.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

typedef int esp_err_t;

#define ESP_OK 0

#ifdef __cplusplus
}
#endif
27 changes: 26 additions & 1 deletion src/estd/port/esp-idf/fake/esp_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,36 @@
// DEBT: Would be better to use a wholistic logging system which included ESP target
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>

//#define LOG_LOCAL_LEVEL

//#define ESP_LOG_LEVEL

enum esp_log_level_t
{
ESP_LOG_NONE,
ESP_LOG_ERROR,
ESP_LOG_WARN,
ESP_LOG_INFO,
ESP_LOG_DEBUG,
ESP_LOG_VERBOSE
};

#define ESP_LOGE(tag, fmt...) { printf("E %s: ", tag); printf(fmt); puts(""); }
#define ESP_LOGW(tag, fmt...) { printf("W %s: ", tag); printf(fmt); puts(""); }
#define ESP_LOGI(tag, fmt...) { printf("I %s: ", tag); printf(fmt); puts(""); }
#define ESP_LOGD(tag, fmt...) { printf("D %s: ", tag); printf(fmt); puts(""); }
#define ESP_LOGV(tag, fmt...) { printf("V %s: ", tag); printf(fmt); puts(""); }

#define ESP_LOG_BUFFER_HEX(tag, buffer, len)
#define ESP_LOG_BUFFER_HEX(tag, buffer, len)

void esp_log_write(esp_log_level_t level, const char *tag, const char *format, ...);

#ifdef __cplusplus
}
#endif
3 changes: 3 additions & 0 deletions test/catch/experimental-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
//#include <estd/locale.h>
#include "estd/exp/unique_handle.h"

// DEBT: Move this out to a 'port.cpp' test
#include <estd/port/esp-idf/fake/esp_log.h>

using namespace estd::test;

struct Test
Expand Down

0 comments on commit 96c3e64

Please sign in to comment.