📄 lvlog.h
字号:
//=====================================================================
//[HEADER] LVLOG
// Multi-component, platform independent message logging.
//+
//[AUTHOR]
// Christian Stapfer
//.
#ifndef LVLOG_H
#define LVLOG_H
#include <stdarg.h>
#include <stdio.h>
#include <lvdef.h>
#ifndef _NOT_EDITOR
#include "lvlog.sh"
#endif
#ifdef _MSC_VER
# ifdef __WIN3264__
# include <windows.h>
# ifdef _LVLOG_
# define LVLOGENTRY __declspec(dllexport)
# else
# define LVLOGENTRY __declspec(dllimport)
# endif
# else
# include <windows.h>
# define LVLOGENTRY __export FAR CDECL
# endif
#else
#ifdef _Windows
# include <windows.h>
# define LVLOGENTRY __export FAR CDECL
#else
# define LVLOGENTRY
# define FAR
# define CDECL
#endif
#endif
#include <lvpackon.h>
#ifdef __cplusplus
extern "C" {
#endif
// -- Component-specific plaintext translation table structure:
typedef struct {
char FAR *szPref; /* Module specific prefix */
char FAR *szName; /* Plaintext name */
unsigned min; /* First status value defined */
unsigned nFormat; /* Index of first char of format
* of this module.
*/
} LVLOG_MODULE;
typedef struct LVLOG_TABLE {
unsigned char major,minor;/* Version ID of LVSTATUS.PL/LVLOG */
unsigned char id[2]; /* ID of generated table */
char FAR *szPref; /* Component specific prefix */
char FAR *szName; /* Plaintext name */
char FAR *szFile; /* File holding externalized fmts */
unsigned min,max; /* Range [min:max] actually used */
LVLOG_MODULE FAR *pModule; /* Pointer to module array */
int nModules; /* Total number of modules */
unsigned char FAR *szFormat; /* Pointer to format array */
} LVLOG_TABLE;
// typedef struct LVLOG_TABLE LVLOG_TABLE;
typedef enum {
LVINFO = 0,
LVWARNING,
LVERROR,
LVFATAL
} LVSEVERITY;
// -- Information functions:
LVLOGAPI LVSEVERITY LVLOGENTRY LvSeverity(LVSTATUS);
LVLOGAPI long LVLOGENTRY LvLogCount(LVSEVERITY);
// -- Message logging functions:
LVLOGAPI LVSTATUS LVLOGENTRY LvLog(LVSTATUS, const char FAR *, unsigned, ...);
LVLOGAPI LVSTATUS LVLOGENTRY LvLogAssert(int, LVSTATUS, const char FAR *,
unsigned, ...);
LVLOGAPI LVSTATUS LVLOGENTRY LvLogPlain(LVSTATUS, const char FAR *, unsigned);
LVLOGAPI LVSTATUS LVLOGENTRY LvLogAssertPlain(int, LVSTATUS, const char FAR *,
unsigned);
// -- Severity level of logged messages: (default is INFO)
LVLOGAPI LVSEVERITY LVLOGENTRY LvLogSetLevel(LVSEVERITY);
// -- Search path to files holding externalized message formats
// can be defined by: (default is current dir, only)
LVLOGAPI void LVLOGENTRY LvLogSetPath(char FAR *);
// -- Attaching of callbacks to the log stream:
#ifdef _MSC_VER
typedef void (FAR CDECL *LVLOG_CALLBACK)
#else
typedef void FAR CDECL (*LVLOG_CALLBACK)
#endif
(void FAR *, // Context
const char FAR*, const char FAR*, // Component
const char FAR*, const char FAR*, // Module
LVSEVERITY, // Severity level
const char FAR*, // Format
const char FAR*, unsigned, // File/Line
va_list // ..
);
#ifdef _MSC_VER
LVLOGAPI LVLOGENTRY void FAR* LvLogAttach(LVLOG_CALLBACK, void FAR *, int);
#else
LVLOGAPI void FAR* LVLOGENTRY LvLogAttach(LVLOG_CALLBACK, void FAR *, int);
#endif
LVLOGAPI void LVLOGENTRY LvLogDetach(void FAR *);
LVLOGAPI void LVLOGENTRY LvLogDetachAll(void);
// -- Registering of component-specific translation tables:
LVLOGAPI void LVLOGENTRY LvLogRegister(const LVLOG_TABLE FAR *);
LVLOGAPI void LVLOGENTRY LvLogUnRegister(const LVLOG_TABLE FAR *);
// -- Example callback implementations:
LVLOGAPI void LVLOGENTRY LvLogStderr(void FAR*, const char FAR *, const char FAR *,
const char FAR*, const char FAR*, LVSEVERITY,
const char FAR*, const char FAR*, unsigned ,
va_list);
LVLOGAPI void LVLOGENTRY LvLogWinDlg(void FAR* , const char FAR*, const char FAR*,
const char FAR*, const char FAR*, LVSEVERITY,
const char FAR*, const char FAR*, unsigned ,
va_list);
typedef struct {
unsigned long valid;
} LVLOG_FILE;
#ifdef _MSC_VER
typedef void (FAR CDECL *LVLOG_FILE_CALLBACK)
#else
typedef void FAR CDECL (*LVLOG_FILE_CALLBACK)
#endif
(FILE FAR*, // Open file handle to write on..
void FAR*, // Context
const char FAR*, const char FAR*, // Component
const char FAR*, const char FAR*, // Module
LVSEVERITY, // Severity level
const char FAR*, // Format
const char FAR*, unsigned, // File/Line
va_list // ..
);
LVLOGAPI LVSTATUS LVLOGENTRY LvLogFileStart(const char FAR*, int, int,
LVLOG_FILE_CALLBACK, void FAR*, int,
const LVLOG_FILE FAR* FAR*, unsigned BufferSize);
LVLOGAPI LVSTATUS LVLOGENTRY LvLogFilePrintf(const LVLOG_FILE FAR*,
const char FAR*, ...);
LVLOGAPI LVSTATUS LVLOGENTRY LvLogFileVprintf(const LVLOG_FILE FAR*,
const char FAR*, va_list);
LVLOGAPI LVSTATUS LVLOGENTRY LvLogFileStop(const LVLOG_FILE FAR*);
#ifdef __cplusplus
} /* end extern "C" */
#endif
#include <lvpackof.h>
#endif /* ndef LVLOG_H */
//-[HEADER] LVLOG
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -