Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / platform / ESP32 / Logging.cpp
1 /* See Project CHIP LICENSE file for licensing information. */
2
3 #include <platform/logging/LogV.h>
4
5 #include <core/CHIPConfig.h>
6 #include <support/logging/Constants.h>
7
8 #include <stdio.h>
9
10 #ifdef LOG_LOCAL_LEVEL
11 #undef LOG_LOCAL_LEVEL
12 #endif
13 #define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
14
15 #include "esp_log.h"
16
17 namespace chip {
18 namespace Logging {
19 namespace Platform {
20
21 void LogV(const char * module, uint8_t category, const char * msg, va_list v)
22 {
23     char tag[11];
24
25     snprintf(tag, sizeof(tag), "chip[%s]", module);
26     tag[sizeof(tag) - 1] = 0;
27
28     char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
29     vsnprintf(formattedMsg, sizeof(formattedMsg), msg, v);
30
31     switch (category)
32     {
33     case kLogCategory_Error:
34         ESP_LOGE(tag, "%s", formattedMsg);
35         break;
36     case kLogCategory_Progress:
37     default:
38         ESP_LOGI(tag, "%s", formattedMsg);
39         break;
40     case kLogCategory_Detail:
41         ESP_LOGV(tag, "%s", formattedMsg);
42         break;
43     }
44 }
45
46 } // namespace Platform
47 } // namespace Logging
48 } // namespace chip