You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.3 KiB
C
79 lines
2.3 KiB
C
/****************************************************************************
|
|
** File name : HTLogger.h
|
|
** Description : logger function define
|
|
** Create date : 2018.09.01
|
|
** Auther by : Liuyx
|
|
** Version info : V1.0.01
|
|
** Copyright (C) 2002-2018 xi'an huatek, Inc Co., Ltd
|
|
** Update record:
|
|
** DATE AUTHER DESC
|
|
** -------------------------------------------------------------------------
|
|
** 2018.09.01 Liuyx first build
|
|
****************************************************************************/
|
|
#ifndef __HT_LOGGER_H
|
|
#define __HT_LOGGER_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif /* __cplusplus */
|
|
|
|
// logger config parameter
|
|
#ifdef _WIN32
|
|
static const char *DEF_LOG_PATH_NAME = ".\\log" ; //日志文件目录名
|
|
static const char *DEF_RUN_INFO_PATH = ".\\run" ; // 服务运行状态日志目录
|
|
#define DEF_PID_FILE "./run/pid_file.pid" // 程序主进程ID文件
|
|
#else
|
|
static const char *DEF_LOG_PATH_NAME = "../log" ; //日志文件目录名
|
|
static const char *DEF_RUN_INFO_PATH = "../run" ; // 服务运行状态日志目录
|
|
#define DEF_PID_FILE "../run/pid_file.pid" // 程序主进程ID文件
|
|
#endif
|
|
|
|
|
|
// 打印报文类型,日志
|
|
#define PRT_PACK_SEND 0 // 打印发送报文类型
|
|
#define PRT_PACK_RECV 1 // 打印接收报文类型
|
|
#define PRT_PACK_DATA 2 // 打印报文
|
|
|
|
#define DEF_LOG_FILESZIE 1048576*50 /* logfile size define 50M byte */
|
|
|
|
#ifdef LOG_DEBUG
|
|
#undef LOG_DEBUG
|
|
#endif
|
|
#define __LOG_DEBUG 0 // 跟踪日志
|
|
#define LOG_DEBUG __LINE__, _FILE_, __LOG_DEBUG
|
|
|
|
#ifdef LOG_WARNG
|
|
#undef LOG_WARNG
|
|
#endif
|
|
#define __LOG_WARNG 1 // 告警日志
|
|
#define LOG_WARNG __LINE__, _FILE_, __LOG_WARNG
|
|
|
|
#ifdef LOG_ERROR
|
|
#undef LOG_ERROR
|
|
#endif
|
|
#define __LOG_ERROR 2 // 错误日志
|
|
#define LOG_ERROR __LINE__, _FILE_, __LOG_ERROR
|
|
|
|
#ifdef LOG_PACK
|
|
#undef LOG_PACK
|
|
#endif
|
|
#define __LOG_PACK 3 // 报文日志
|
|
#define LOG_PACK __LINE__, _FILE_, __LOG_PACK
|
|
|
|
// 日志记录相关函数
|
|
void vInitLogMutex(void);
|
|
void vFreeLogMutex(void);
|
|
|
|
void vPrtLogMsg(int line, const char *pszFileName, char logLevel, int iCode, ...);
|
|
void vPrtLogHex(int line, const char *pszFileName, char logLevel, int sockid, /* unsigned short msg_id, */
|
|
char pszMsgType, unsigned char *pusMsg,int uiMsgLen);
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif // __HT_LOGGER_H
|
|
|