1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
/**********************************************************************************
* log.h
*
* Include file for liblog.a. Coding? Include this and link against liblog.a.
*
* At this time; its a simple list manager but I expect that this will evolve into
* a list manager which;
*
* - allows for messages of different severity and types to be stored
* - allows for actions (such as saving to file or poping) to occur on selected message
* types and severities
*
**********************************************************************************/
#ifndef INCLUDED_LOG_H
#define INCLUDED_LOG_H
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <lst.h>
/*****************************************************************************
* FUNCTION RETURN CODES
*****************************************************************************/
#define LOG_ERROR 0
#define LOG_SUCCESS 1
#define LOG_NO_DATA 2
/*****************************************************************************
* SEVERITY
*****************************************************************************/
#define LOG_INFO 0
#define LOG_WARNING 1
#define LOG_CRITICAL 2
/*****************************************************************************
*
*****************************************************************************/
#define LOG_MSG_MAX 1024
/*****************************************************************************
* HANDLES
*****************************************************************************/
typedef struct tLOGMSG
{
char *pszModuleName; /* liblog will malloc, copy, and free */
char *pszFunctionName; /* liblog will malloc, copy, and free */
int nLine;
int nSeverity;
int nCode;
char *pszMessage; /* liblog will malloc, copy, and free */
} LOGMSG, *HLOGMSG;
typedef struct tLOG
{
HLST hMessages; /* list of messages ( LOGMSG ) */
char *pszProgramName; /* liblog will malloc, copy, and free */
char *pszLogFile; /* NULL, or filename */
long nMaxMsgs; /* OLDEST WILL BE DELETED ONCE MAX */
int bOn; /* turn logging on/off (default=off) */
} LOG, *HLOG;
/*****************************************************************************
* API
*****************************************************************************/
/******************************
* logOpen
*
******************************/
int logOpen( HLOG *phLog, char *pszProgramName, char *pszLogFile, long nMaxMsgs );
/******************************
* logClose
*
******************************/
int logClose( HLOG hLog );
/******************************
* logPushMsg
*
******************************/
int logPushMsg( HLOG hLog, char *pszModule, char *pszFunctionName, int nLine, int nSeverity, int nCode, char *pszMsg );
int logPushMsgv( HLOG hLog, char *pszModule, char *pszFunctionName, int nLine, int nSeverity, int nCode, ... );
/******************************
* logPopMsg
*
* 1. Pops last message from stack and deletes it.
* 2. Message returned in pszMsg (make sure its large enough)
******************************/
int logPopMsg( HLOG hLog, char *pszMsgHdr, int *pnCode, char *pszMsg );
/******************************
* logOn
*
* 1. if false then no storage on memory or file
* 2. default is false
* 3. you may want to turn logging on off for
* debugging purposes
******************************/
int logOn( HLOG hLog, int bOn );
/*****************************************************************************
* SUPPORTING FUNCS (do not call directly)
*****************************************************************************/
/******************************
* _logFreeMsg
*
* 1. This is called by lstDelete()
******************************/
void _logFreeMsg( void *pMsg );
#endif
|