Files
microchip-application-pec93…/Common/syslog.h
T
2026-02-03 11:37:13 +08:00

108 lines
3.6 KiB
C

/**
* Copyright (c) 2024 Wei-Lun Hsu. All Rights Reserved.
*/
/** @file syslog.h
*
* @author Wei-Lun Hsu
* @version 0.1
* @date 2024/08/29
* @license
* @description
*/
#ifndef __syslog_H_wWjHKLEN_l9U5_H1mZ_sZEW_uX5M5YmrWbVp__
#define __syslog_H_wWjHKLEN_l9U5_H1mZ_sZEW_uX5M5YmrWbVp__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
#include "printf.h"
//=============================================================================
// Constant Definition
//=============================================================================
/**
* System Log message through uart with baudrate 'SLOG_SERIAL_BPS'
*/
#define SLOG_SERIAL_BPS 115200
#define SLOG_BLACK "\033[30m"
#define SLOG_RED "\033[31m"
#define SLOG_GREEN "\033[32m"
#define SLOG_YELLOW "\033[33m"
#define SLOG_BLUE "\033[34m"
#define SLOG_MAGENTA "\033[35m"
#define SLOG_CYAN "\033[36m"
#define SLOG_WHITE "\033[97m"
#define SLOG_DEFAULT "\033[39m"
#define SLOG_RESET "\033[m"
#define SLOG_RED2 "\33[91m"
#define SLOG_GREEN2 "\33[92m"
#define SLOG_YELLOW2 "\33[93m"
#define SLOG_BLUE2 "\33[94m"
#define SLOG_VIOLET2 "\33[95m"
#define SLOG_BEIGE2 "\33[96m"
//=============================================================================
// Macro Definition
//=============================================================================
#define stringize(s) #s
#define _toStr(a) stringize(a)
#define err(str, ...) printf(SLOG_RED "[error] " str SLOG_RESET, ##__VA_ARGS__)
#if defined(NDEBUG)
/* release */
#define info(str, ...)
#define msg(str, ...)
#define dbg(str, ...)
#define log_color(COLOR, str, ...)
#else
#define info(str, ...) printf(SLOG_YELLOW str SLOG_RESET, ##__VA_ARGS__)
#define msg(str, ...) printf(str, ##__VA_ARGS__)
#define dbg(str, ...) printf(str, ##__VA_ARGS__)
#define log_color(COLOR, str, ...) printf(COLOR str SLOG_RESET, ##__VA_ARGS__)
#endif /* NDEBUG */
//=============================================================================
// Structure Definition
//=============================================================================
//=============================================================================
// Global Data Definition
//=============================================================================
//=============================================================================
// Private Function Definition
//=============================================================================
//=============================================================================
// Public Function Definition
//=============================================================================
void syslog_init(void);
/**
* \brief Dump memory data through system log
*
* \param [in] prefix the prefix text
* \param [in] pAddr the target memory address
* \param [in] bytes the dumped length
* \param [in] has_out_u32le layout with 32-bits little-endian or not
* \return
* None
*/
void
syslog_dump_mem(
char *prefix,
uint32_t *pAddr,
int bytes,
int has_out_u32le);
#ifdef __cplusplus
}
#endif
#endif