/* * This program source code file is part of SystemK, a library in the KTag project. * * 🛡️ 🃞 * * Copyright © 2016-2025 Joseph P. Kearney and the KTag developers. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * There should be a copy of the GNU Affero General Public License in the LICENSE * file in the root of this repository. If not, see . */ #ifdef ESP_PLATFORM #include #define KLOG_ERROR(tag, format, ...) ESP_LOGE(tag, format, ##__VA_ARGS__) #define KLOG_WARN(tag, format, ...) ESP_LOGW(tag, format, ##__VA_ARGS__) #define KLOG_INFO(tag, format, ...) ESP_LOGI(tag, format, ##__VA_ARGS__) #define KLOG_DEBUG(tag, format, ...) ESP_LOGD(tag, format, ##__VA_ARGS__) #define KLOG_TRACE(tag, format, ...) ESP_LOGV(tag, format, ##__VA_ARGS__) #endif // ESP_PLATFORM #ifdef PSOC_PLATFORM /* Include PSoC system and component APIs and defines */ #include #include #define MAX_KLOG_STRING_LENGTH (255) extern char8 KLog_Buffer[MAX_KLOG_STRING_LENGTH]; #define KLOG_ERROR(tag, format, ...) \ do \ { \ UART_Console_PutString("ERROR ["); \ UART_Console_PutString(tag); \ UART_Console_PutString("] "); \ sprintf((char8 *)KLog_Buffer, format, ##__VA_ARGS__); \ UART_Console_PutString((const char8 *)KLog_Buffer); \ UART_Console_PutString("\n"); \ } while (false) #define KLOG_WARN(tag, format, ...) \ do \ { \ UART_Console_PutString("WARN ["); \ UART_Console_PutString(tag); \ UART_Console_PutString("] "); \ sprintf((char8 *)KLog_Buffer, format, ##__VA_ARGS__); \ UART_Console_PutString((const char8 *)KLog_Buffer); \ UART_Console_PutString("\n"); \ } while (false) #define KLOG_INFO(tag, format, ...) \ do \ { \ UART_Console_PutString("INFO ["); \ UART_Console_PutString(tag); \ UART_Console_PutString("] "); \ sprintf((char8 *)KLog_Buffer, format, ##__VA_ARGS__); \ UART_Console_PutString((const char8 *)KLog_Buffer); \ UART_Console_PutString("\n"); \ } while (false) #define KLOG_DEBUG(tag, format, ...) \ do \ { \ UART_Console_PutString("DEBUG ["); \ UART_Console_PutString(tag); \ UART_Console_PutString("] "); \ sprintf((char8 *)KLog_Buffer, format, ##__VA_ARGS__); \ UART_Console_PutString((const char8 *)KLog_Buffer); \ UART_Console_PutString("\n"); \ } while (false) #define KLOG_TRACE(tag, format, ...) \ do \ { \ UART_Console_PutString("TRACE ["); \ UART_Console_PutString(tag); \ UART_Console_PutString("] "); \ sprintf((char8 *)KLog_Buffer, format, ##__VA_ARGS__); \ UART_Console_PutString((const char8 *)KLog_Buffer); \ UART_Console_PutString("\n"); \ } while (false) #endif // PSOC_PLATFORM