1 /* See Project chip LICENSE file for licensing information. */
3 #include <platform/logging/LogV.h>
4 #include <support/logging/Constants.h>
6 #include <core/CHIPConfig.h>
7 #include <support/logging/Constants.h>
19 void LogV(const char * module, uint8_t category, const char * msg, va_list v)
21 char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE];
22 int32_t prefixLen = snprintf(formattedMsg, sizeof(formattedMsg), "CHIP: [%s] ", module);
25 // This should not happen
29 if (static_cast<size_t>(prefixLen) >= sizeof(formattedMsg))
31 prefixLen = sizeof(formattedMsg) - 1;
34 vsnprintf(formattedMsg + prefixLen, sizeof(formattedMsg) - static_cast<size_t>(prefixLen), msg, v);
38 case kLogCategory_Error:
39 os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_ERROR, "🔴 %{public}s", formattedMsg);
40 #if TARGET_OS_MAC && TARGET_OS_IPHONE == 0
41 fprintf(stdout, "\033[1;31m");
45 case kLogCategory_Progress:
46 os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_INFO, "🔵 %{public}s", formattedMsg);
47 #if TARGET_OS_MAC && TARGET_OS_IPHONE == 0
48 fprintf(stdout, "\033[0;32m");
52 case kLogCategory_Detail:
53 os_log_with_type(OS_LOG_DEFAULT, OS_LOG_TYPE_DEBUG, "🟢 %{public}s", formattedMsg);
54 #if TARGET_OS_MAC && TARGET_OS_IPHONE == 0
55 fprintf(stdout, "\033[0;34m");
59 #if TARGET_OS_MAC && TARGET_OS_IPHONE == 0
60 fprintf(stdout, "%s\033[0m\n", formattedMsg);
64 } // namespace Platform
65 } // namespace Logging