mirror of
https://github.com/NevermindZZT/letter-shell.git
synced 2025-01-21 10:02:54 +08:00
修改 几处 gcc 编译的警告
优化 log组件支持 cpp
This commit is contained in:
parent
c823f6403d
commit
693d3d0fc8
@ -121,7 +121,7 @@ static void logWriteBuffer(Log *log, LogLevel level, char *buffer, short len)
|
||||
* @param fmt 格式
|
||||
* @param ... 参数
|
||||
*/
|
||||
void logWrite(Log *log, LogLevel level, char *fmt, ...)
|
||||
void logWrite(Log *log, LogLevel level, const char *fmt, ...)
|
||||
{
|
||||
va_list vargs;
|
||||
short len;
|
||||
@ -201,6 +201,7 @@ void logHexDump(Log *log, LogLevel level, void *base, unsigned int length)
|
||||
}
|
||||
}
|
||||
}
|
||||
logBuffer[printLen ++] = ' ';
|
||||
logBuffer[printLen ++] = '|';
|
||||
logBuffer[printLen ++] = '\r';
|
||||
logBuffer[printLen ++] = '\n';
|
||||
@ -214,7 +215,7 @@ void logHexDump(Log *log, LogLevel level, void *base, unsigned int length)
|
||||
SHELL_EXPORT_CMD_AGENCY(
|
||||
SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_DISABLE_RETURN,
|
||||
hexdump, logHexDump, hex dump\r\n hexdump [base] [len],
|
||||
(void *)shellCompanionGet(shellGetCurrent(), SHELL_COMPANION_ID_LOG), LOG_NONE, p1, p2);
|
||||
(void *)shellCompanionGet(shellGetCurrent(), SHELL_COMPANION_ID_LOG), LOG_NONE, (void *)p1, (unsigned int)p2);
|
||||
#else
|
||||
SHELL_EXPORT_CMD(
|
||||
SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_DISABLE_RETURN,
|
||||
|
@ -11,6 +11,10 @@
|
||||
#ifndef __LOG_H__
|
||||
#define __LOG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /**< defined __cplusplus */
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
#define LOG_VERSION "1.0.1"
|
||||
@ -22,9 +26,12 @@
|
||||
#define LOG_MAX_NUMBER 5 /**< 允许注册的最大log对象数量 */
|
||||
#define LOG_AUTO_TAG 1 /**< 是否自动添加TAG */
|
||||
#define LOG_END "\r\n" /**< log信息结尾 */
|
||||
#define LOG_TAG __FUNCTION__ /**< 自定添加的TAG */
|
||||
#define LOG_TIME_STAMP 0 /**< 设置获取系统时间戳 */
|
||||
|
||||
#ifndef LOG_TAG
|
||||
#define LOG_TAG __FUNCTION__ /**< 自定添加的TAG */
|
||||
#endif
|
||||
|
||||
#ifndef LOG_ENABLE
|
||||
#define LOG_ENABLE 1 /**< 使能log */
|
||||
#endif
|
||||
@ -52,17 +59,17 @@
|
||||
#define CSI_WHITE_L 97 /**< 亮白 */
|
||||
#define CSI_DEFAULT 39 /**< 默认 */
|
||||
|
||||
#define CSI(code) "\033["#code"m" /**< ANSI CSI指令 */
|
||||
#define CSI(code) "\033[" #code "m" /**< ANSI CSI指令 */
|
||||
|
||||
/**
|
||||
* log级别字符(包含颜色)
|
||||
*/
|
||||
#if LOG_USING_COLOR == 1
|
||||
#define ERROR_TEXT CSI(31)"E(%d) %s:"CSI(39) /**< 错误标签 */
|
||||
#define WARNING_TEXT CSI(33)"W(%d) %s:"CSI(39) /**< 警告标签 */
|
||||
#define INFO_TEXT CSI(32)"I(%d) %s:"CSI(39) /**< 信息标签 */
|
||||
#define DEBUG_TEXT CSI(34)"D(%d) %s:"CSI(39) /**< 调试标签 */
|
||||
#define VERBOSE_TEXT CSI(36)"V(%d) %s:"CSI(39) /**< 冗余信息标签 */
|
||||
#define ERROR_TEXT CSI(31) "E(%d) %s:" CSI(39) /**< 错误标签 */
|
||||
#define WARNING_TEXT CSI(33) "W(%d) %s:" CSI(39) /**< 警告标签 */
|
||||
#define INFO_TEXT CSI(32) "I(%d) %s:" CSI(39) /**< 信息标签 */
|
||||
#define DEBUG_TEXT CSI(34) "D(%d) %s:" CSI(39) /**< 调试标签 */
|
||||
#define VERBOSE_TEXT CSI(36) "V(%d) %s:" CSI(39) /**< 冗余信息标签 */
|
||||
#else
|
||||
#define ERROR_TEXT "E(%d) %s:"
|
||||
#define WARNING_TEXT "W(%d) %s:"
|
||||
@ -109,7 +116,7 @@ typedef struct
|
||||
* @param ... 参数
|
||||
*/
|
||||
#define logPrintln(format, ...) \
|
||||
logWrite(LOG_ALL_OBJ, LOG_NONE, format"\r\n", ##__VA_ARGS__)
|
||||
logWrite(LOG_ALL_OBJ, LOG_NONE, format "\r\n", ##__VA_ARGS__)
|
||||
|
||||
|
||||
/**
|
||||
@ -122,7 +129,7 @@ typedef struct
|
||||
*/
|
||||
#define logFormat(text, level, fmt, ...) \
|
||||
if (LOG_ENABLE) {\
|
||||
logWrite(LOG_ALL_OBJ, level, text" "fmt""LOG_END, \
|
||||
logWrite(LOG_ALL_OBJ, level, text " " fmt "" LOG_END, \
|
||||
LOG_TIME_STAMP, LOG_TAG, ##__VA_ARGS__); }
|
||||
|
||||
/**
|
||||
@ -194,7 +201,11 @@ typedef struct
|
||||
void logRegister(Log *log, Shell *shell);
|
||||
void logUnRegister(Log *log);
|
||||
void logSetLevel(Log *log, LogLevel level);
|
||||
void logWrite(Log *log, LogLevel level, char *fmt, ...);
|
||||
void logWrite(Log *log, LogLevel level, const char *fmt, ...);
|
||||
void logHexDump(Log *log, LogLevel level, void *base, unsigned int length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /**< defined __cplusplus */
|
||||
|
||||
#endif
|
||||
|
@ -373,7 +373,7 @@ static void shellWritePrompt(Shell *shell, unsigned char newline)
|
||||
* @param fmt 格式化字符串
|
||||
* @param ... 参数
|
||||
*/
|
||||
void shellPrint(Shell *shell, char *fmt, ...)
|
||||
void shellPrint(Shell *shell, const char *fmt, ...)
|
||||
{
|
||||
char buffer[SHELL_PRINT_BUFFER];
|
||||
va_list vargs;
|
||||
|
@ -440,7 +440,7 @@ typedef struct
|
||||
void shellInit(Shell *shell, char *buffer, unsigned short size);
|
||||
void shellRemove(Shell *shell);
|
||||
unsigned short shellWriteString(Shell *shell, const char *string);
|
||||
void shellPrint(Shell *shell, char *fmt, ...);
|
||||
void shellPrint(Shell *shell, const char *fmt, ...);
|
||||
void shellScan(Shell *shell, char *fmt, ...);
|
||||
Shell* shellGetCurrent(void);
|
||||
void shellHandler(Shell *shell, char data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user