📄 zvlog.h
字号:
#ifndef ZEVIOLOG_H_#define ZEVIOLOG_H_#ifdef __cplusplusextern "C" {#endif/******************************************************************************** Log Level Definitions ** ** These definitions represent the standard logging levels. They control ** whether or not a given log entry will actually be compiled into the code. ** ** For example, if you wanted to log a certain fatal error in the Sequencer ** component, you could use ZEVIO_LOG( ZEVIO_LOG_SEQUENCER, ZEVIO_LOG_FATAL, SOME_ERROR )** which would generate a log entry only when ZEVIO_LOG_SEQUENCER is set to at ** least ZEVIO_LOG_FATAL in the header ZEVIOlogs.h. ** ** The standard for using the log levels is as follows. ** ** ZEVIO_LOG_NONE: Do not ever use this in any ZEVIO_LOG call. It is present so ** that logging for a given component can always be shut down by ** changing only this file. ** ZEVIO_LOG_FATAL: Serious errors that result in the system being broken, such as ** hardware failures or bugs. These log entries are always ** turned on in production code. ** ZEVIO_LOG_MAJOR: Major errors, or major commands that are recorded to track the ** behavior of the system. These log entries are always turned ** on in production code. ** ZEVIO_LOG_MINOR: Additional minor errors, inconsistencies, or commands. ** ZEVIO_LOG_DEBUG: Information useful to assist in debugging of development code. ** These entries are never turned on in production code. ** ********************************************************************************/#define ZEVIO_LOG_NONE 0#define ZEVIO_LOG_FATAL 1#define ZEVIO_LOG_MAJOR 2#define ZEVIO_LOG_MINOR 3#define ZEVIO_LOG_DEBUG 4/******************************************************************************** Component Log Levels ** ** These definitions set the current logging levels for all components in the ** system. ** ********************************************************************************/// System Initialization#define ZEVIO_LOG_STARTUP ZEVIO_LOG_MAJOR// Sequencers#define ZEVIO_LOG_OPENGLCMD ZEVIO_LOG_MAJOR/******************************************************************************** Log Macros ** ** Use these macros to add entries to the log. DO NOT call the log procedures ** directly to do this, always use these macros. ZEVIO_LOG0 through ZEVIO_LOG6 add ** entries of 0 through 6 words to the log. ZEVIO_LOGP adds a log entry based on ** the specified size and pointer. ** ** Log macros are presently not compiled for any target which does not support ** vxWorks. ** ********************************************************************************/#define ZEVIO_LOGP(G, L, ID, S, E) if( G >= L ) ZEVIOLogAddEntryByRef( ID, L, S, (unsigned int *)(E) );#define ZEVIO_LOGV(G, L, ID, N, V...) if( G >= L) ZEVIOLogAddEntryV(ID, L, N, ## V);#define ZEVIO_LOG(G, L, ID) ZEVIO_LOG0(G, L, ID)#define ZEVIO_LOG0(G, L, ID) if( G >= L ) ZEVIOLogAddEntry( ID, L, 0, 0, 0, 0, 0, 0, 0 );#define ZEVIO_LOG1(G, L, ID, A) if( G >= L ) ZEVIOLogAddEntry( ID, L, 1, (unsigned int)(A), 0, 0, 0, 0, 0 );#define ZEVIO_LOG2(G, L, ID, A, B) if( G >= L ) ZEVIOLogAddEntry( ID, L, 2, (unsigned int)(A), (unsigned int)(B), 0, 0, 0, 0 );#define ZEVIO_LOG3(G, L, ID, A, B, C) if( G >= L ) ZEVIOLogAddEntry( ID, L, 3, (unsigned int)(A), (unsigned int)(B), (unsigned int)(C), 0, 0, 0 );#define ZEVIO_LOG4(G, L, ID, A, B, C, D) if( G >= L ) ZEVIOLogAddEntry( ID, L, 4, (unsigned int)(A), (unsigned int)(B), (unsigned int)(C), (unsigned int)(D), 0, 0 );#define ZEVIO_LOG5(G, L, ID, A, B, C, D, E) if( G >= L ) ZEVIOLogAddEntry( ID, L, 5, (unsigned int)(A), (unsigned int)(B), (unsigned int)(C), (unsigned int)(D), (unsigned int)(E), 0 );#define ZEVIO_LOG6(G, L, ID, A, B, C, D, E, F) if( G >= L ) ZEVIOLogAddEntry( ID, L, 6, (unsigned int)(A), (unsigned int)(B), (unsigned int)(C), (unsigned int)(D), (unsigned int)(E), (unsigned int)(F) );/******************************************************************************** Log Structure ** ** This is the data structure for the log itself. It is maintained as a ring ** buffer containing variable-size entries. ** ********************************************************************************/#define ZEVIO_LOG_MAX_PARAM_LENGTH 128 // Maximum length of the params (e.g FTP settings)#define ZEVIO_LOG_BUFFER_SIZE 64*1024#define ZEVIO_ASSERT assert#include "zvLogEvents.h" // Log event IDs and data structurestypedef enum { ZEVIO_SUCCESS = 0, ZEVIO_ERR_FAIL , ZEVIO_ERR_INVALID } retCode;typedef struct { char host[ZEVIO_LOG_MAX_PARAM_LENGTH]; char username[ZEVIO_LOG_MAX_PARAM_LENGTH]; char password[ZEVIO_LOG_MAX_PARAM_LENGTH]; char filename[ZEVIO_LOG_MAX_PARAM_LENGTH]; int ctrlSock; int dataSock;} ZEVIOLogFTPStructure;typedef struct { char device [ZEVIO_LOG_MAX_PARAM_LENGTH]; int fd;} ZEVIOLogDevStructure;typedef struct { ZEVIOLogFTPStructure ftp; ZEVIOLogDevStructure dev; int (*printEngine)(char *str); char filter[ZEVIO_LOG_MAX_PARAM_LENGTH];} ZEVIOLogOutputStructure;typedef struct{ unsigned int *pBase; unsigned int size; unsigned int numEntries; unsigned int firstEntry; unsigned int nextEntry; int active; int wraparound; int overflow; ZEVIOLogOutputStructure *outS;} ZEVIOLogStructure;/******************************************************************************** Log Access Procedures ** ** These procedures are used to initialize and access the log. LogInit is ** called only during ZEVIOareInit. LogAddEntry and LogAddEntryByRef should not ** be called directly, use the ZEVIO_LOG macros defined above instead. ** ********************************************************************************/retCode ZEVIOLogInit ( unsigned int logSize );retCode ZEVIOlogClearBuffer ();retCode ZEVIOLogConfig ( int wraparound );retCode ZEVIOLogAddEntry ( ZEVIO_LOG_EVENT event, unsigned int level, unsigned int numParams, unsigned int param1, unsigned int param2, unsigned int param3, unsigned int param4, unsigned int param5, unsigned int param6 );retCode ZEVIOLogAddEntryV ( ZEVIO_LOG_EVENT event, unsigned int level, unsigned int numParams, ... );retCode ZEVIOLogAddEntryByRef ( ZEVIO_LOG_EVENT event, unsigned int level, unsigned int numParams, unsigned int *params );retCode ZEVIOLogSuspend ();retCode ZEVIOLogResume ();ZEVIOLogStructure *ZEVIOLogGet ();#ifdef __cplusplus}#endif#endif // ZEVIOLOG_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -