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.

377 lines
12 KiB
C

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/****************************************************************************/
/* Copyright (c) 2007,许继集团有限公司 */
/* All rights reserved. */
/* */
/* 模块描述: */
/** 实现多种log信息的输出
* @file ai_log.h */
/* */
/* 日期 作者 注释 */
/* 2007/07/24 TYJ 创建文件 */
/****************************************************************************/
#ifndef IEC61850_AI_LOG_H
#define IEC61850_AI_LOG_H
#include "ai_def.h"
#include "slog.h"
#ifdef __cplusplus
extern "C"{
#endif
#define AI_LOG_FILE_EN
//#define AI_LOG_STDOUT_EN
#define AI_LOG_USER_EN
#define AI_LOG_FILE_NAME "iec61850.log" /**< 默认日志输出的文件名 */
#define AI_LOG_FILE_SIZE 1000000L /**< 文件最大不超过1M */
#define AI_LOG_ERR 0x00000001 /**< 错误日志信息标志 */
#define AI_LOG_FLOW 0x00000002 /**< 流程日志信息标志 */
#define AI_LOG_DATA 0x00000004 /**< 数据日志信息标志 */
#define AI_LOG_TEST 0x00000008 /**< 测试日志信息标志 */
extern ST_UINT ai_log_sel; /**< 日志信息类型 */
extern SD_CONST ST_CHAR *SD_CONST ai_log_err_logstr; /**< 错误日志信息标题描述 */
extern SD_CONST ST_CHAR *SD_CONST ai_log_flow_logstr; /**< 流程日志信息标题描述 */
extern SD_CONST ST_CHAR *SD_CONST ai_log_data_logstr; /**< 数据日志信息标题描述 */
extern SD_CONST ST_CHAR *SD_CONST ai_log_test_logstr; /**< 测试日志信息标题描述 */
/**
* 用户自定义日志输出接口,产生日志时会调用此接口输出日志
* @param logStr 要输出的日志信息
* @return ST_VOID
*/
extern ST_VOID (*user_log_put)(ST_CHAR *logStr);
/**
* 输出错误日志信息.
* 输出包括日志的类型、时间、源文件名以及行数等信息其中fmt为描述信息a、b...为参数的值
*/
#if defined(DEBUG_SISCO) /**< 日志输出编译条件 */
#define AI_LOG_FUN_ERR0(fmt) {\
if(ai_log_sel & AI_LOG_ERR) \
_slog (sLogCtrl, ai_log_err_logstr, thisFileName, __LINE__, fmt);}
#define AI_LOG_FUN_ERR1(fmt,a) {\
if (ai_log_sel & AI_LOG_ERR) \
_slog (sLogCtrl, ai_log_err_logstr, thisFileName, __LINE__, fmt,a);}
#define AI_LOG_FUN_ERR2(fmt,a,b) {\
if (ai_log_sel & AI_LOG_ERR) \
_slog (sLogCtrl, ai_log_err_logstr, thisFileName, __LINE__, fmt,a, b);}
#define AI_LOG_FUN_ERR3(fmt,a,b,c) {\
if (ai_log_sel & AI_LOG_ERR) \
_slog (sLogCtrl, ai_log_err_logstr, thisFileName, __LINE__, fmt,a, b, c);}
#define AI_LOG_FUN_ERR4(fmt,a,b,c,d) {\
if (ai_log_sel & AI_LOG_ERR) \
_slog (sLogCtrl, ai_log_err_logstr, thisFileName, __LINE__, fmt,a, b, c, d);}
#define AI_LOG_FUN_ERR5(fmt,a,b,c,d,e) {\
if (ai_log_sel & AI_LOG_ERR) \
_slog (sLogCtrl, ai_log_err_logstr, thisFileName, __LINE__, fmt,a, b, c, d, e);}
#define AI_LOG_FUN_ERR6(fmt,a,b,c,d,e,f) {\
if (ai_log_sel & AI_LOG_ERR) \
_slog (sLogCtrl, ai_log_err_logstr, thisFileName, __LINE__, fmt,a, b, c, d, e, f);}
#else
#define AI_LOG_FUN_ERR0(fmt)
#define AI_LOG_FUN_ERR1(fmt,a)
#define AI_LOG_FUN_ERR2(fmt,a,b)
#define AI_LOG_FUN_ERR3(fmt,a,b,c)
#define AI_LOG_FUN_ERR4(fmt,a,b,c,d)
#define AI_LOG_FUN_ERR5(fmt,a,b,c,d,e)
#define AI_LOG_FUN_ERR6(fmt,a,b,c,d,e,f)
#endif
/**
* 输出流程日志信息.
* 输出包括日志的类型、时间、源文件名以及行数等信息其中fmt为描述信息a、b...为参数的值
*/
#if defined(DEBUG_SISCO) /**< 日志输出编译条件 */
#define AI_LOG_FUN_FLOW0(fmt) {\
if(ai_log_sel & AI_LOG_FLOW) \
_slog (sLogCtrl, ai_log_flow_logstr, thisFileName, __LINE__, fmt);}
#define AI_LOG_FUN_FLOW1(fmt,a) {\
if (ai_log_sel & AI_LOG_FLOW) \
_slog (sLogCtrl, ai_log_flow_logstr, thisFileName, __LINE__, fmt,a);}
#define AI_LOG_FUN_FLOW2(fmt,a,b) {\
if (ai_log_sel & AI_LOG_FLOW) \
_slog (sLogCtrl, ai_log_flow_logstr, thisFileName, __LINE__, fmt,a, b);}
#define AI_LOG_FUN_FLOW3(fmt,a,b,c) {\
if (ai_log_sel & AI_LOG_FLOW) \
_slog (sLogCtrl, ai_log_flow_logstr, thisFileName, __LINE__, fmt,a, b, c);}
#define AI_LOG_FUN_FLOW4(fmt,a,b,c,d) {\
if (ai_log_sel & AI_LOG_FLOW) \
_slog (sLogCtrl, ai_log_flow_logstr, thisFileName, __LINE__, fmt,a, b, c, d);}
#define AI_LOG_FUN_FLOW5(fmt,a,b,c,d,e) {\
if (ai_log_sel & AI_LOG_FLOW) \
_slog (sLogCtrl, ai_log_flow_logstr, thisFileName, __LINE__, fmt,a, b, c, d, e);}
#define AI_LOG_FUN_FLOW6(fmt,a,b,c,d,e,f) {\
if (ai_log_sel & AI_LOG_FLOW) \
_slog (sLogCtrl, ai_log_flow_logstr, thisFileName, __LINE__, fmt,a, b, c, d, e, f);}
#else
#define AI_LOG_FUN_FLOW0(fmt)
#define AI_LOG_FUN_FLOW1(fmt,a)
#define AI_LOG_FUN_FLOW2(fmt,a,b)
#define AI_LOG_FUN_FLOW3(fmt,a,b,c)
#define AI_LOG_FUN_FLOW4(fmt,a,b,c,d)
#define AI_LOG_FUN_FLOW5(fmt,a,b,c,d,e)
#define AI_LOG_FUN_FLOW6(fmt,a,b,c,d,e,f)
#endif
/**
* 输出测试日志信息.
* 输出包括日志的类型、时间、源文件名以及行数等信息其中fmt为描述信息a、b...为参数的值
*/
#if defined(DEBUG_SISCO) /**< 日志输出编译条件 */
#define AI_LOG_FUN_TEST0(fmt) {\
if(ai_log_sel & AI_LOG_TEST) \
_slog (sLogCtrl, ai_log_test_logstr, thisFileName, __LINE__, fmt);}
#define AI_LOG_FUN_TEST1(fmt,a) {\
if (ai_log_sel & AI_LOG_TEST) \
_slog (sLogCtrl, ai_log_test_logstr, thisFileName, __LINE__, fmt,a);}
#define AI_LOG_FUN_TEST2(fmt,a,b) {\
if (ai_log_sel & AI_LOG_TEST) \
_slog (sLogCtrl, ai_log_test_logstr, thisFileName, __LINE__, fmt,a, b);}
#define AI_LOG_FUN_TEST3(fmt,a,b,c) {\
if (ai_log_sel & AI_LOG_TEST) \
_slog (sLogCtrl, ai_log_test_logstr, thisFileName, __LINE__, fmt,a, b, c);}
#define AI_LOG_FUN_TEST4(fmt,a,b,c,d) {\
if (ai_log_sel & AI_LOG_TEST) \
_slog (sLogCtrl, ai_log_test_logstr, thisFileName, __LINE__, fmt,a, b, c, d);}
#define AI_LOG_FUN_TEST5(fmt,a,b,c,d,e) {\
if (ai_log_sel & AI_LOG_TEST) \
_slog (sLogCtrl, ai_log_test_logstr, thisFileName, __LINE__, fmt,a, b, c, d, e);}
#define AI_LOG_FUN_TEST6(fmt,a,b,c,d,e,f) {\
if (ai_log_sel & AI_LOG_TEST) \
_slog (sLogCtrl, ai_log_test_logstr, thisFileName, __LINE__, fmt,a, b, c, d, e, f);}
#else
#define AI_LOG_FUN_TEST0(fmt)
#define AI_LOG_FUN_TEST1(fmt,a)
#define AI_LOG_FUN_TEST2(fmt,a,b)
#define AI_LOG_FUN_TEST3(fmt,a,b,c)
#define AI_LOG_FUN_TEST4(fmt,a,b,c,d)
#define AI_LOG_FUN_TEST5(fmt,a,b,c,d,e)
#define AI_LOG_FUN_TEST6(fmt,a,b,c,d,e,f)
#endif
/**
* 输出数据日志信息.
* 输出包括日志的类型、时间、源文件名以及行数等信息其中fmt为描述信息a、b...为参数的值
*/
#if defined(DEBUG_SISCO) /**< 日志输出编译条件 */
#define AI_LOG_FUN_DATA0(fmt) {\
if(ai_log_sel & AI_LOG_DATA) \
_slog (sLogCtrl, ai_log_data_logstr, thisFileName, __LINE__, fmt);}
#define AI_LOG_FUN_DATA1(fmt,a) {\
if (ai_log_sel & AI_LOG_DATA) \
_slog (sLogCtrl, ai_log_data_logstr, thisFileName, __LINE__, fmt,a);}
#define AI_LOG_FUN_DATA2(fmt,a,b) {\
if (ai_log_sel & AI_LOG_DATA) \
_slog (sLogCtrl, ai_log_data_logstr, thisFileName, __LINE__, fmt,a, b);}
#define AI_LOG_FUN_DATA3(fmt,a,b,c) {\
if (ai_log_sel & AI_LOG_DATA) \
_slog (sLogCtrl, ai_log_data_logstr, thisFileName, __LINE__, fmt,a, b, c);}
#define AI_LOG_FUN_DATA4(fmt,a,b,c,d) {\
if (ai_log_sel & AI_LOG_DATA) \
_slog (sLogCtrl, ai_log_data_logstr, thisFileName, __LINE__, fmt,a, b, c, d);}
#define AI_LOG_FUN_DATA5(fmt,a,b,c,d,e) {\
if (ai_log_sel & AI_LOG_DATA) \
_slog (sLogCtrl, ai_log_data_logstr, thisFileName, __LINE__, fmt,a, b, c, d, e);}
#define AI_LOG_FUN_DATA6(fmt,a,b,c,d,e,f) {\
if (ai_log_sel & AI_LOG_DATA) \
_slog (sLogCtrl, ai_log_data_logstr, thisFileName, __LINE__, fmt,a, b, c, d, e, f);}
#else
#define AI_LOG_FUN_DATA0(fmt)
#define AI_LOG_FUN_DATA1(fmt,a)
#define AI_LOG_FUN_DATA2(fmt,a,b)
#define AI_LOG_FUN_DATA3(fmt,a,b,c)
#define AI_LOG_FUN_DATA4(fmt,a,b,c,d)
#define AI_LOG_FUN_DATA5(fmt,a,b,c,d,e)
#define AI_LOG_FUN_DATA6(fmt,a,b,c,d,e,f)
#endif
/**
* 输出错误日志信息.
* 输出不再包含日志的类型、时间、源文件名以及行数等信息,直接显示用户数据信息。
* 其中fmt为描述信息a、b...为参数的值
*/
#if defined(DEBUG_SISCO) /**< 日志输出编译条件 */
#define AI_LOG_FUN_ERRC0(fmt) {\
if(ai_log_sel & AI_LOG_ERR) _slogc (sLogCtrl, fmt);}
#define AI_LOG_FUN_ERRC1(fmt,a) {\
if (ai_log_sel & AI_LOG_ERR) _slogc (sLogCtrl, fmt,a);}
#define AI_LOG_FUN_ERRC2(fmt,a,b) {\
if (ai_log_sel & AI_LOG_ERR) _slogc (sLogCtrl, fmt,a, b);}
#define AI_LOG_FUN_ERRC3(fmt,a,b,c) {\
if (ai_log_sel & AI_LOG_ERR) _slogc (sLogCtrl, fmt,a, b, c);}
#define AI_LOG_FUN_ERRC4(fmt,a,b,c,d) {\
if (ai_log_sel & AI_LOG_ERR) _slogc (sLogCtrl, fmt,a, b, c, d);}
#define AI_LOG_FUN_ERRC5(fmt,a,b,c,d,e) {\
if (ai_log_sel & AI_LOG_ERR) _slogc (sLogCtrl, fmt,a, b, c, d, e);}
#define AI_LOG_FUN_ERRC6(fmt,a,b,c,d,e,f) {\
if (ai_log_sel & AI_LOG_ERR) _slogc (sLogCtrl, fmt,a, b, c, d, e, f);}
#else
#define AI_LOG_FUN_ERRC0(fmt)
#define AI_LOG_FUN_ERRC1(fmt,a)
#define AI_LOG_FUN_ERRC2(fmt,a,b)
#define AI_LOG_FUN_ERRC3(fmt,a,b,c)
#define AI_LOG_FUN_ERRC4(fmt,a,b,c,d)
#define AI_LOG_FUN_ERRC5(fmt,a,b,c,d,e)
#define AI_LOG_FUN_ERRC6(fmt,a,b,c,d,e,f)
#endif
/**
* 输出流程日志信息.
* 输出不再包含日志的类型、时间、源文件名以及行数等信息,直接显示用户数据信息。
* 其中fmt为描述信息a、b...为参数的值
*/
#if defined(DEBUG_SISCO) /**< 日志输出编译条件 */
#define AI_LOG_FUN_FLOWC0(fmt) {\
if(ai_log_sel & AI_LOG_FLOW) _slogc (sLogCtrl, fmt);}
#define AI_LOG_FUN_FLOWC1(fmt,a) {\
if (ai_log_sel & AI_LOG_FLOW) _slogc (sLogCtrl, fmt,a);}
#define AI_LOG_FUN_FLOWC2(fmt,a,b) {\
if (ai_log_sel & AI_LOG_FLOW) _slogc (sLogCtrl, fmt,a, b);}
#define AI_LOG_FUN_FLOWC3(fmt,a,b,c) {\
if (ai_log_sel & AI_LOG_FLOW) _slogc (sLogCtrl, fmt,a, b, c);}
#define AI_LOG_FUN_FLOWC4(fmt,a,b,c,d) {\
if (ai_log_sel & AI_LOG_FLOW) _slogc (sLogCtrl, fmt,a, b, c, d);}
#define AI_LOG_FUN_FLOWC5(fmt,a,b,c,d,e) {\
if (ai_log_sel & AI_LOG_FLOW) _slogc (sLogCtrl, fmt,a, b, c, d, e);}
#define AI_LOG_FUN_FLOWC6(fmt,a,b,c,d,e,f) {\
if (ai_log_sel & AI_LOG_FLOW) _slogc (sLogCtrl, fmt,a, b, c, d, e, f);}
#else
#define AI_LOG_FUN_FLOWC0(fmt)
#define AI_LOG_FUN_FLOWC1(fmt,a)
#define AI_LOG_FUN_FLOWC2(fmt,a,b)
#define AI_LOG_FUN_FLOWC3(fmt,a,b,c)
#define AI_LOG_FUN_FLOWC4(fmt,a,b,c,d)
#define AI_LOG_FUN_FLOWC5(fmt,a,b,c,d,e)
#define AI_LOG_FUN_FLOWC6(fmt,a,b,c,d,e,f)
#endif
/**
* 输出测试日志信息.
* 输出不再包含日志的类型、时间、源文件名以及行数等信息,直接显示用户数据信息。
* 其中fmt为描述信息a、b...为参数的值
*/
#if defined(DEBUG_SISCO) /**< 日志输出编译条件 */
#define AI_LOG_FUN_TESTC0(fmt) {\
if(ai_log_sel & AI_LOG_TEST) _slogc (sLogCtrl, fmt);}
#define AI_LOG_FUN_TESTC1(fmt,a) {\
if (ai_log_sel & AI_LOG_TEST) _slogc (sLogCtrl, fmt,a);}
#define AI_LOG_FUN_TESTC2(fmt,a,b) {\
if (ai_log_sel & AI_LOG_TEST) _slogc (sLogCtrl, fmt,a, b);}
#define AI_LOG_FUN_TESTC3(fmt,a,b,c) {\
if (ai_log_sel & AI_LOG_TEST) _slogc (sLogCtrl, fmt,a, b, c);}
#define AI_LOG_FUN_TESTC4(fmt,a,b,c,d) {\
if (ai_log_sel & AI_LOG_TEST) _slogc (sLogCtrl, fmt,a, b, c, d);}
#define AI_LOG_FUN_TESTC5(fmt,a,b,c,d,e) {\
if (ai_log_sel & AI_LOG_TEST) _slogc (sLogCtrl, fmt,a, b, c, d, e);}
#define AI_LOG_FUN_TESTC6(fmt,a,b,c,d,e,f) {\
if (ai_log_sel & AI_LOG_TEST) _slogc (sLogCtrl, fmt,a, b, c, d, e, f);}
#else
#define AI_LOG_FUN_TESTC0(fmt)
#define AI_LOG_FUN_TESTC1(fmt,a)
#define AI_LOG_FUN_TESTC2(fmt,a,b)
#define AI_LOG_FUN_TESTC3(fmt,a,b,c)
#define AI_LOG_FUN_TESTC4(fmt,a,b,c,d)
#define AI_LOG_FUN_TESTC5(fmt,a,b,c,d,e)
#define AI_LOG_FUN_TESTC6(fmt,a,b,c,d,e,f)
#endif
/**
* 输出数据日志信息.
* 输出不再包含日志的类型、时间、源文件名以及行数等信息,直接显示用户数据信息。
* 其中fmt为描述信息a、b...为参数的值
*/
#if defined(DEBUG_SISCO) /**< 日志输出编译条件 */
#define AI_LOG_FUN_DATAC0(fmt) {\
if(ai_log_sel & AI_LOG_DATA) \
_slogc (sLogCtrl, fmt);}
#define AI_LOG_FUN_DATAC1(fmt,a) {\
if (ai_log_sel & AI_LOG_DATA) _slogc (sLogCtrl, fmt,a);}
#define AI_LOG_FUN_DATAC2(fmt,a,b) {\
if (ai_log_sel & AI_LOG_DATA) _slogc (sLogCtrl, fmt,a, b);}
#define AI_LOG_FUN_DATAC3(fmt,a,b,c) {\
if (ai_log_sel & AI_LOG_DATA) _slogc (sLogCtrl, fmt,a, b, c);}
#define AI_LOG_FUN_DATAC4(fmt,a,b,c,d) {\
if (ai_log_sel & AI_LOG_DATA) _slogc (sLogCtrl, fmt,a, b, c, d);}
#define AI_LOG_FUN_DATAC5(fmt,a,b,c,d,e) {\
if (ai_log_sel & AI_LOG_DATA) _slogc (sLogCtrl, fmt,a, b, c, d, e);}
#define AI_LOG_FUN_DATAC6(fmt,a,b,c,d,e,f) {\
if (ai_log_sel & AI_LOG_DATA) _slogc (sLogCtrl, fmt,a, b, c, d, e, f);}
#else
#define AI_LOG_FUN_DATAC0(fmt)
#define AI_LOG_FUN_DATAC1(fmt,a)
#define AI_LOG_FUN_DATAC2(fmt,a,b)
#define AI_LOG_FUN_DATAC3(fmt,a,b,c)
#define AI_LOG_FUN_DATAC4(fmt,a,b,c,d)
#define AI_LOG_FUN_DATAC5(fmt,a,b,c,d,e)
#define AI_LOG_FUN_DATAC6(fmt,a,b,c,d,e,f)
#endif
/**
* 设置用户自定义日志输出接口
*/
ST_VOID ai_init_log(ST_VOID);
#ifdef __cplusplus
}
#endif
#endif