[libimdb-commit] CVS: libimdb/include/jlog Makefile,NONE,1.1 dic.errors,NONE,1.1 jlog.h,NONE,1.1 jlo
Status: Pre-Alpha
Brought to you by:
jveldhuis
|
From: Jerry V. <jve...@us...> - 2003-06-16 04:18:48
|
Update of /cvsroot/libimdb/libimdb/include/jlog
In directory sc8-pr-cvs1:/tmp/cvs-serv11812/include/jlog
Added Files:
Makefile dic.errors jlog.h jlog2File.h jlogTracker.h mklog.pl
par.errors
Log Message:
initial checkin
--- NEW FILE: Makefile ---
#
# $Id: Makefile,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $
#
include ../../config.mk
include ../../constants.mk
GENERATED_HDRS := $(patsubst %.errors, %err.h, $(wildcard *.errors))
TEMPFILE = .tmpf-$(OS)
# to make clean/clobber targets in rules.mk happy
OBJS = $(TEMPFILE)
build: $(GENERATED_HDRS)
%err.h: %.errors mklog.pl Makefile
$(PERL) mklog.pl $* $< > $(TEMPFILE)
$(CMP) -s $(TEMPFILE) $@ || $(MV) $(TEMPFILE) $@
clobber::
$(RM) -f $(GENERATED_HDRS)
include ../../rules.mk
--- NEW FILE: dic.errors ---
DICE_BAD_MEM "memory failed"
DICE_FILE_OPEN "open %s failed (%s)"
--- NEW FILE: jlog.h ---
/**
@file
The jlog library provides a consistant and reliable logging mechanism for
critical error, general error, warning and debugging messages.
It is designed to be easy to use, and to take advantage of compiler
options to minimize coding errors. For instance using ansi declarations
and the use of #defines to wrap var-arg entry points.
The jlog library supports the concept of modules so that levels and
details of logging are managed on a per-module basis.
Modules are defined statically in an enumeration (@see jlogmod_e) to
ensure uniquiness (and quicker execution within the jlog library).
Typically, but not neccessarily, each modules' messages to the jlog
library are generated by defining a message definition file.
This helps enumerate possible jlog messages (critical, error and
warnings) and promptes proper error tracking, further simplifies the
jlog interface and message re-use within a module. See jlog/jlog/mklog.pl
for details on how to use.
@todo can the return code of one jlogCallbackHandle effect if the rest
get called ?
@todo ENTER/SUCCESS/FAILURE macros should have compile time option for disabling
each individually.
@todo should have simple clone() function or somehow be able to temperarily
disable all error/warning reporting etc during clean-up code (see todo in swtable.c)
@verbatim $Id: jlog.h,v 1.1 2003/06/16 04:18:37 jveldhuis Exp $ @endverbatim
*/
#ifndef JLOG_H
# define JLOG_H
/** @enum jlogmod_e
* one for each logical "module".
*/
typedef enum {
MOD_NONE=0, /**< must be first */
MOD_JLG=1, /**< libjlog */
MOD_PAR=2, /**< libimdb parser */
MOD_DIC=3, /**< libimdb dict */
MOD_ALL=4 /**< must be last */
} jlogModule_e;
/**
* @enum jlogReportLevel_e
* Four levels of logging.
*/
typedef enum {
JLOGT_DEBUG=2, /**< debug message */
JLOGT_ERROR=1, /**< error message */
JLOGT_CRITICAL=0, /**< critical error message */
} jlogReportLevel_e;
#ifndef SWIG
typedef struct jlog_s jlogHandle_t;
/* this should be jlog_Complex_callback_t */
typedef void (jlog_eventCallback_t)(jlogHandle_t *logh, const char *srcfile, const char *srcfunc,
int srcline, jlogModule_e module, jlogReportLevel_e jlogReportLevel,
int messageNumber, const char *messageText, void *cb_extra);
#endif
/**
* typedef for callbacks from the jlog library.
*/
jlogHandle_t *
jlog_openMain(jlogHandle_t *reuseh, const char *file, const char *function, int lineno);
#define jlog_open(reuseh) jlog_openMain(reuseh, __FILE__, __FUNC__, __LINE__)
#define jlog_openNew() jlog_openMain(NULL, __FILE__, __FUNC__, __LINE__)
int
jlog_close(jlogHandle_t *logh);
#ifdef SWIGJAVA
%apply char **MYSTATIC_STRING_ARRAY_RET {char **jlog_getModuleShortNames}
#endif
char **jlog_getModuleShortNames(const jlogHandle_t *logh);
#ifdef SWIGJAVA
%clear char **jlog_getModuleShortNames;
#endif
#ifndef SWIGJAVA
/** @todo we should support multiple of these
* and return code should determine if next one gets called etc
* should create a callback definition, define userdata, define callback
* level
*/
typedef struct jlogCallbackHandle_s jlogCallbackHandle_t;
jlogCallbackHandle_t *
jlogCallback_create(jlog_eventCallback_t *cb, void *userdata);
void
jlogCallback_destroy(jlogCallbackHandle_t *l);
int
jlogCallback_setNotificationLevel(jlogCallbackHandle_t *cbHandle,
jlogModule_e module,
jlogReportLevel_e level);
int
jlog_registerEventCallback(jlogHandle_t *logh,
jlogCallbackHandle_t *cb);
int
jlog_unregisterEventCallback(jlogHandle_t *logh,
jlogCallbackHandle_t *cb);
#endif /* SWIGJAVA */
jlogModule_e
jlog_messageModule(const jlogHandle_t *logh, jlogReportLevel_e level);
int
jlog_messageNumber(const jlogHandle_t *logh, jlogReportLevel_e level);
/** clear the message stack, set jlog_errmodule to MOD_NONE,
* and jlog_messageNumber to 0
*/
int
jlog_reset(jlogHandle_t *logh);
/**
* enable/disable enter exit calls for a given module
*/
int
jlog_setModuleDebugEnterExit(jlogHandle_t *logh, jlogModule_e module, int on);
/**
* enable/disable enter exit calls for all modules
*/
int
jlog_setAllModuleDebugEnterExit(jlogHandle_t *logh, int on);
#ifndef SWIG
/**
* @def MAXJLOGMSGLEN
* For performance reasons, we statically define maximum message length at compile time.
*/
#define MAXJLOGMSGLEN (4048)
#endif /* SWIG */
#ifndef __GNUC__
/**
* @def __attribute__
* undefine unless we're using a gnuc compiler
*/
#define __attribute__(def)
#endif
#if defined(_USE_STDARG)
int
jlog_fmt_arglist(jlogHandle_t *logh, jlogReportLevel_e jlogReportLevel, jlogModule_e module, int messageNumber,
const char *srcfile, const char *srcfunc, int srcline, const char *fmt, va_list ap);
/** @def JLOG_FMT_ARG
* convenience macro calling jlog_fmt_arglist with proper compile time location
* information.
*/
#define JLOG_FMT_ARG(jlogh, jlogReportLevel, module, messageNumber, fmt, ap) \
jlog_fmt_arglist(jlogh, jlogReportLevel, module, messageNumber, __FILE__, __FUNC__, __LINE__, fmt, ap)
#endif
#ifndef SWIG
int
jlog_fmt(jlogHandle_t *jlogh, jlogReportLevel_e jlogReportLevel, jlogModule_e module, int messageNumber,
const char *srcfile, const char *srcfunc, int srcline, const char *fmt, ...);
/**
* @def jlog_msg
* wrapper for calling jlog_fmt_arglist with no args.
*/
#define jlog_msg(jlogh, jlogReportLevel, module, messageNumber, srcfile, srcfunc, srcline, fmt) \
(jlog_fmt(jlogh, jlogReportLevel, module, messageNumber, srcfile, srcfunc, srcline, fmt, NULL))
#endif /* SWIG */
int
jlog_fmtfile(jlogHandle_t *jlogh, jlogReportLevel_e jlogReportLevel, jlogModule_e module, int messageNumber,
const char *srcfile, const char *srcfunc, int srcline, const char *file);
#ifndef SWIG
/** @def JLOG_FMT
* convenience macro calling jlog_fmtfile with proper compile time location information.
*/
#define JLOG_FMTFILE(jlogh, jlogReportLevel, module, messageNumber, file) \
jlog_fmtfile(jlogh, jlogReportLevel, module, messageNumber, __FILE__, __FUNC__, __LINE__, file)
/** @def JLOG_FMT
* convenience macro calling jlog_fmt with proper compile time location information.
*/
#define JLOG_FMT(jlogh, jlogReportLevel, module, mess) \
jlog_msg(jlogh, jlogReportLevel, module, -1, __FILE__, __FUNC__, __LINE__, mess)
/* Critical Macros ;) */
/** @def JLOG_CRITICAL
* jlog a critical message associated with the given module.
*/
#define JLOG_CRITICAL(jlogh, module, mess) \
jlog_msg(jlogh, JLOGT_CRITICAL, module, -1, __FILE__, __FUNC__, __LINE__, mess)
/** @def JLOG_CRITICAL1
* jlog a critical message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_CRITICAL1(jlogh, module, fmt, a1) \
jlog_fmt(jlogh, JLOGT_CRITICAL, module, -1, __FILE__, __FUNC__, __LINE__, fmt, a1)
/** @def JLOG_CRITICAL2
* jlog a critical message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_CRITICAL2(jlogh, module, fmt, a1, a2) \
jlog_fmt(jlogh, JLOGT_CRITICAL, module, -1, __FILE__, __FUNC__, __LINE__, fmt, a1, a2)
/** @def JLOG_CRITICAL3
* jlog a critical message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_CRITICAL3(jlogh, module, fmt, a1, a2, a3) \
jlog_fmt(jlogh, JLOGT_CRITICAL, module, -1, __FILE__, __FUNC__, __LINE__, fmt, a1, a2, a3)
/* ERR Macros */
/** @def JLOG_ERROR
* jlog an error message associated with the given module.
*/
#define JLOG_ERROR(jlogh, module, errn, mess) \
jlog_msg(jlogh, JLOGT_ERROR, module, errn, __FILE__, __FUNC__, __LINE__, mess)
/** @def JLOG_ERROR1
* jlog an error message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_ERROR1(jlogh, module, errn, fmt, a1) \
jlog_fmt(jlogh, JLOGT_ERROR, module, errn, __FILE__, __FUNC__, __LINE__, fmt, a1)
/** @def JLOG_ERROR2
* jlog an error message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_ERROR2(jlogh, module, errn, fmt, a1, a2) \
jlog_fmt(jlogh, JLOGT_ERROR, module, errn, __FILE__, __FUNC__, __LINE__, fmt, a1, a2)
/** @def JLOG_ERROR3
* jlog an error message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_ERROR3(jlogh, module, errn, fmt, a1, a2, a3) \
jlog_fmt(jlogh, JLOGT_ERROR, module, errn, __FILE__, __FUNC__, __LINE__, fmt, a1, a2, a3)
/** @def JLOG_WARNING
* jlog a warning message associated with the given module.
*/
#define JLOG_WARNING(jlogh, module, mess) \
jlog_msg(jlogh, JLOGT_WARNING, module, -1, __FILE__, __FUNC__, __LINE__, mess)
/** @def JLOG_WARNING1
* jlog a warning message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_WARNING1(jlogh, module, fmt, a1) \
jlog_fmt(jlogh, JLOGT_WARNING, module, -1, __FILE__, __FUNC__, __LINE__, fmt, a1)
/** @def JLOG_WARNING2
* jlog a warning message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_WARNING2(jlogh, module, fmt, a1, a2) \
jlog_fmt(jlogh, JLOGT_WARNING, module, -1, __FILE__, __FUNC__, __LINE__, fmt, a1)
/** @def JLOG_WARNING3
* jlog a warning message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_WARNING3(jlogh, module, fmt, a1, a2, a3) \
jlog_fmt(jlogh, JLOGT_WARNING, module, -1, __FILE__, __FUNC__, __LINE__, fmt, a1, a2, a3)
/* DEBUG Macros */
/** @def JLOG_DBG_FILE
* jlog the contents of a file as debug message for a given module.
*/
#define JLOG_DBG_FILE(jlogh, module, file) \
JLOG_FMTFILE(jlogh, JLOGT_DEBUG, module, -1, file)
/** @def JLOG_DBG
* jlog a debug message associated with the given module.
*/
#define JLOG_DBG(H, mod, mess) \
jlog_msg(H, JLOGT_DEBUG, mod, -1, __FILE__, __FUNC__, __LINE__, mess)
/** @def JLOG_DBG0
* jlog a debug message associated with the given module.
*/
#define JLOG_DBG0(H, mod, mess) JLOG_DBG(H, mod, mess)
/** @def JLOG_DBG1
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG1(H, mod, f, a1) \
jlog_fmt(H, JLOGT_DEBUG, mod, -1, __FILE__, __FUNC__, __LINE__,f,a1)
/** @def JLOG_DBG2
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG2(H, mod, f, a1, a2) \
jlog_fmt(H, JLOGT_DEBUG, mod, -1, __FILE__, __FUNC__, __LINE__,f,a1,a2)
/** @def JLOG_DBG3
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG3(H, mod, f, a1, a2, a3) \
jlog_fmt(H, JLOGT_DEBUG, mod, -1, __FILE__, __FUNC__, __LINE__,f,a1,a2,a3)
/** @def JLOG_DBG4
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG4(H, mod, f, a1, a2, a3, a4) \
jlog_fmt(H, JLOGT_DEBUG, mod, -1, __FILE__, __FUNC__, __LINE__,f,a1,a2,a3,a4)
/** @def JLOG_DBG5
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG5(H, m, f, a1, a2, a3, a4, a5) \
jlog_fmt(H, JLOGT_DEBUG, m, -1, __FILE__, __FUNC__, __LINE__,f,a1,a2,a3,a4,a5)
/** @def JLOG_DBG6
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG6(H, m, f, a1, a2, a3, a4, a5, a6) \
jlog_fmt(H, JLOGT_DEBUG, m, -1, __FILE__, __FUNC__, __LINE__,f,a1,a2,a3,a4,a5,a6)
/** @def JLOG_DBG9
* jlog a debug message associated with the given module.
* Message is a string with following arg(s) being sprintf(buffer, message,a1...)
* compatible.
*/
#define JLOG_DBG9(H, m, f, a1, a2, a3, a4, a5, a6, a7, a8, a9) \
jlog_fmt(H, JLOGT_DEBUG, m, -1, __FILE__, __FUNC__, __LINE__,f,a1,a2,a3,a4,a5,a6,a7,a8,a9)
/**
* @def JLOG_DEBUG
* nice for development, module-independent debugging to default jlogging factilites.
* set environment variable JLOG_DEBUG_LEVEL to "-:+MOD_ALL"
*/
#define JLOG_DEBUG(H,M,f)\
JLOG_DBG0(H,M,f)
#define JLOG_DEBUG0(H,M,f)\
JLOG_DBG0(H,M,f)
#define JLOG_DEBUG1(H,M,f,a1)\
JLOG_DBG1(H,M,f,a1)
#define JLOG_DEBUG2(H,M,f,a1,a2)\
JLOG_DBG2(H,M,f,a1,a2)
#define JLOG_DEBUG3(H,M,f,a1,a2,a3)\
JLOG_DBG3(H,M,f,a1,a2,a3)
#define JLOG_DEBUG4(H,M,f,a1,a2,a3,a4)\
JLOG_DBG4(H,M,f,a1,a2,a3,a4)
#define JLOG_DEBUG5(H,M,f,a1,a2,a3,a4,a5)\
JLOG_DBG5(H,M,f,a1,a2,a3,a4,a5)
#define JLOG_DEBUG6(H,M,f,a1,a2,a3,a4,a5,a6)\
JLOG_DBG6(H,M,f,a1,a2,a3,a4,a5,a6)
#define JLOG_DEBUG7(H,M,f,a0,a1,a2,a3,a4,a5,a6)\
JLOG_DEBUG7(H,M,f,a0,a1,a2,a3,a4,a5,a6)
#define JLOG_DEBUG8(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7)\
JLOG_DEBUG8(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7)
#define JLOG_DEBUG9(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8)\
JLOG_DEBUG9(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8)
#define JLOG_DEBUG10(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)\
JLOG_DEBUG10(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)
#define JLOG_DEBUG11(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)\
JLOG_DEBUG11(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)
#define JLOG_DEBUG12(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)\
JLOG_DEBUG12(H,M,f,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)
/**
* @def JLOG_DEBUG_G
* these are here to ease use of the default jlog facilities for debugging
*/
#define JLOG_DEBUG_G(f) JLOG_DEBUG0(NULL, MOD_ALL, f)
#define JLOG_DEBUG0_G(f) JLOG_DEBUG0(NULL, MOD_ALL, f)
#define JLOG_DEBUG1_G(f,a1) JLOG_DEBUG1(NULL, MOD_ALL, f,a1)
#define JLOG_DEBUG2_G(f,a1,a2) JLOG_DEBUG2(NULL, MOD_ALL, f,a1,a2)
#define JLOG_DEBUG3_G(f,a1,a2,a3) JLOG_DEBUG3(NULL, MOD_ALL, f,a1,a2,a3)
#define JLOG_DEBUG4_G(f,a1,a2,a3,a4) JLOG_DEBUG4(NULL, MOD_ALL, f,a1,a2,a3,a4)
#define JLOG_DEBUG5_G(f,a1,a2,a3,a4,a5) JLOG_DEBUG5(NULL, MOD_ALL, f,a1,a2,a3,a4,a5)
#define JLOG_DEBUG6_G(f,a1,a2,a3,a4,a5,a6) JLOG_DEBUG6(NULL, MOD_ALL, f,a1,a2,a3,a4,a5,a6)
int
jlog_enter(jlogHandle_t *jlogh, jlogReportLevel_e jlogReportLevel, jlogModule_e module,
const char *srcfile, int srcline, const char *srcfunc, ...);
int
jlog_success(jlogHandle_t *jlogh, jlogReportLevel_e jlogReportLevel, jlogModule_e module,
const char *srcfile, int srcline, const char *srcfunc, ...);
int
jlog_failure(jlogHandle_t *jlogh, jlogReportLevel_e jlogReportLevel, jlogModule_e module,
const char *srcfile, int srcline, const char *srcfunc, ...);
/** @def JLOG_ENTER
* @todo - JLOG_ENTER macros could use # special operator so the type arguments
* don't have to be strings.
*/
#define JLOG_ENTER(H, m) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
NULL)
#define JLOG_ENTER0(H, m) JLOG_ENTER(H, m)
#define JLOG_ENTER1(H, m, t1, v1) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, NULL)
#define JLOG_ENTER2(H, m, t1, v1, t2, v2) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, NULL)
#define JLOG_ENTER3(H, m, t1, v1, t2, v2, t3, v3) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, NULL)
#define JLOG_ENTER4(H, m, t1, v1, t2, v2, t3, v3, t4, v4) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, t4, v4, NULL)
#define JLOG_ENTER5(H, m, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, NULL)
#define JLOG_ENTER6(H, m, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, NULL)
#define JLOG_ENTER7(H, m, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, NULL)
#define JLOG_ENTER8(H, m, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8, NULL)
#define JLOG_ENTER9(H, m, t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8, t9, v9) \
jlog_enter(H, JLOGT_DEBUG, m, __FILE__, __LINE__, __FUNC__, \
t1, v1, t2, v2, t3, v3, t4, v4, t5, v5, t6, v6, t7, v7, t8, v8, t9, v9, NULL)
/** @todo note in programming guidelines about how to use JLOG_FAILURE and
* JLOG_SUCCESS along with CRTE_BAD_MEM_FAILURE macros
*/
#define JLOG_FAILURE(H, MODULE, TYPE, VALUE) \
{TYPE __jlog_failure_macro_ret=(VALUE); \
jlog_failure(H, JLOGT_DEBUG, MODULE, __FILE__, __LINE__, __FUNC__, #TYPE, __jlog_failure_macro_ret, NULL); \
return(__jlog_failure_macro_ret);}
#define JLOG_SUCCESS(H, MODULE, TYPE, VALUE) \
{TYPE __jlog_success_macro_ret=(VALUE); \
jlog_success(H, JLOGT_DEBUG, MODULE, __FILE__, __LINE__, __FUNC__, #TYPE, __jlog_success_macro_ret, NULL);\
return(__jlog_success_macro_ret);}
#endif /* SWIG */
#endif /* JLOG_H */
--- NEW FILE: jlog2File.h ---
/**
* @file
*
* simple logCallbackHandle enabled module that logs to a file.
*/
typedef struct jlog2File_s jlog2File_t;
jlog2File_t *
jlog2File_create(char *filename);
int
jlog2File_destroy(jlog2File_t *lt);
int
jlog2File_enable(jlog2File_t *lt);
int
jlog2File_disable(jlog2File_t *lt);
char *
jlog2File_getFilename(jlog2File_t *lt);
jlogCallbackHandle_t *
jlog2File_getJLogCallbackHandle(jlog2File_t *lt);
--- NEW FILE: jlogTracker.h ---
/**
* @file
*
* Simple log tracker class for logging to memory.
*
* @todo LOG_DEBUG env variable should support file/function regexp match.
*
*/
typedef struct jlogTracker_s jlogTracker_t;
jlogTracker_t *
jlogTracker_create(void);
jlogReportLevel_e
jlogTracker_setLevel(jlogTracker_t *lt, jlogReportLevel_e level);
void
jlogTracker_reset(jlogTracker_t *lt);
int
jlogTracker_getCount(jlogTracker_t *lt);
int
jlogTracker_getMessageDetails(jlogTracker_t *lt,
int messageIndex,
char **srcfile,
char **srcfunc,
int *srcline,
jlogModule_e *module,
jlogReportLevel_e *reportLevel,
int *messageNumber,
char **messageText);
jlogCallbackHandle_t *
jlogTracker_getJLogCallbackHandle(jlogTracker_t *lt);
--- NEW FILE: mklog.pl ---
#! /usr/local/bin/perl -w
#
# This script preprocesses the messages defined for a
# single module. The first argument is the name of module (ie sys).
# The second argument (or stdin by default) is the file that
# defines the errorTable for the specified module.
#
# An errorTable is a file with two columns, for example:
# SYSE_GENERAL_ERROR "general error: %s"
# SYSC_GENERAL_CRITICAL "critical message: %s"
# SYSD_GENERAL_DEBUG "general debug message: %s"
#
# For a given module, the module prefix (SYS in this example)
# must appear in log.h header enumeration logmod_e (MOD_SYS).
#
# The output consists of #defines macros that translate the table into
# appropriate calls to log_fmt() that includes the required arguments
# (ie accounts for %s, %d etc in second column strings).
#
# The E_, W_, C_, and D_ cause the second argument to jlog_fmt call
# to be JLOGT_ERROR, JLOGT_CRITICAL and JLOGT_DEBUG as
# appropriate.
#
# The names of the output macros are the first column entry followed
# by _F. So for example, the SYSE_GENERAL_ERROR entry above would appear
# as:
# #define SYSE_GENERAL_ERROR_F(H, a1) \
# jlog_fmt(H, JLOGT_ERROR, MOD_SYS, SYSE_GENERAL_ERROR, \
# __FILE__, __FUNCTION__, __LINE__, "general error: %s", a1);
#
# nice huh ? now you can get some compilers to check you specified a
# valid argument to the macro.
#
# Also as output, a single enumeration that includes all the column 1
# entries, along with a macro for calling jlog_errno() and casting the
# return value to the enumeration.
#
use strict;
my $usage = "usage: $0 moduleName [errorTable]\n";
# errorTable is a file with two columns, eg.
# PRVE_NO_ERROR "error message"
# PRVC_NO_ERROR "critical message"
# PRVD_NO_ERROR "debug message"
my $moduleName = shift || die($usage);
$moduleName = uc($moduleName);
print "#ifndef ${moduleName}_ERROR_H\n";
print "#define ${moduleName}_ERROR_H\n";
print "\n/* for convience */\n#include \"jlog/jlog.h\"\n\n";
my @errors;
my @criticals;
my @debugs;
print "/* convience, so code reads consistant with _FAIL macros */\n";
print "#define ${moduleName}_SUCCESS(H, TYPE, VALUE) JLOG_SUCCESS(H, MOD_$moduleName, TYPE, VALUE)\n\n";
print "#define ${moduleName}_FAILURE(H, TYPE, VALUE) JLOG_FAILURE(H, MOD_$moduleName, TYPE, VALUE)\n";
while (<>) {
chomp;
if ( !m/^$moduleName/o ) {
print "$_\n";
next;
}
my ($name, $msg) = split(' ', $_, 2);
# count % escapes, don't forget about %% though:
my $count = ($msg =~ s/(%.)/$1/g) - ($msg =~ s/(%%)/$1/g);
my $args = "";
for (my $i = 0; $i < $count; $i += 1) {
$args .= ", a$i";
}
my $type;
my $errno;
if ( $name=~m/^${moduleName}E_/o ) {
$type="JLOGT_ERROR";
$errno=$name;
push(@errors, $name);
} elsif ( $name=~m/^${moduleName}C_/o ) {
$type="JLOGT_CRITICAL";
$errno=$name;
push(@criticals, $name);
} elsif ( $name=~m/^${moduleName}D_/o ) {
$type="JLOGT_DEBUG";
$errno=$name;
push(@debugs, $name);
}
print "#define ${name}_F(H$args)\\\n";
print "\tjlog_fmt(H, $type, MOD_$moduleName, $errno, __FILE__, __FUNC__, __LINE__, ".$msg."$args)\n";
if ( $type eq "JLOGT_ERROR" ||
$type eq "JLOGT_CRITICAL" ) {
print "#define ${name}_FAILURE(H$args, TYPE, VALUE)\\\n";
print "\t{${name}_F(H$args); JLOG_FAILURE(H, MOD_$moduleName, TYPE, VALUE);}\n\n";
}
print "\n";
}
my $number=0;
if ( @criticals ) {
print "\ntypedef enum {\n";
for (@criticals) {
print " $_=$number,\n";
$number++;
}
print "} ${moduleName}critical_e;\n";
}
else {
print "\n/* no criticals, so enumeration becomes an int */\n";
print "typedef int ${moduleName}critical_e;\n";
}
if ( @errors ) {
print "\ntypedef enum {\n";
for (@errors) {
print " $_=$number,\n";
$number++;
}
print "} ${moduleName}error_e;\n";
}
else {
print "\n/* no errors, so enumeration becomes an int */\n";
print "typedef int ${moduleName}error_e;\n";
}
if ( @debugs ) {
print "\ntypedef enum {\n";
for (@debugs) {
print " $_=$number,\n";
$number++;
}
print "} ${moduleName}debug_e;\n";
}
else {
print "\n/* no debugs, so enumeration becomes an int */\n";
print "typedef int ${moduleName}debug_e;\n";
}
print "\n";
if ( @criticals && scalar(@criticals) == 1 ) {
print "#define is${moduleName}criticalNumber(N)\t(N==".$criticals[0].")\n";
}
elsif ( @criticals && scalar(@criticals) > 1 ) {
print "#define is${moduleName}criticalNumber(N)\t(N>=".$criticals[0].
" && N<=".$criticals[scalar(@criticals)-1].")\n";
}
else {
print "#define is${moduleName}criticalNumber(N)\t(0)\n";
}
if ( @errors && scalar(@errors) == 1 ) {
print "#define is${moduleName}errorNumber(N)\t(N==".$errors[0].")\n";
}
elsif ( @errors && scalar(@errors) > 1 ) {
print "#define is${moduleName}errorsNumber(N)\t(N>=".$errors[0].
" && N<=".$errors[scalar(@errors)-1].")\n";
}
else {
print "#define is${moduleName}errorNumber(N)\t(0)\n";
}
if ( @debugs && scalar(@debugs) == 1 ) {
print "#define is${moduleName}debugNumber(N)\t(N==".$debugs[0].")\n";
}
elsif ( @debugs && scalar(@debugs) > 1 ) {
print "#define is${moduleName}debugsNumber(N)\t(N>=".$debugs[0].
" && N<=".$debugs[scalar(@debugs)-1].")\n";
}
else {
print "#define is${moduleName}debugNumber(N)\t(0)\n";
}
print "\n";
print "#define ${moduleName}criticalNumber(LOGH) (${moduleName}critical_e)jlog_messageNumber(LOGH, JLOGT_CRITICAL)\n";
print "#define ${moduleName}errorNumber(LOGH) (${moduleName}error_e)jlog_messageNumber(LOGH, JLOGT_ERROR)\n";
print "#define ${moduleName}debugNumber(LOGH) (${moduleName}debug_e)jlog_messageNumber(LOGH, JLOGT_DEBUG)\n";
print "\n";
print "#define ${moduleName}_DEBUG(H,f)\\\n";
print "\tjlog_msg(H,JLOGT_DEBUG,MOD_${moduleName},-1,__FILE__,__FUNC__,__LINE__,f)\n";
for (my $i=0; $i<=12 ; $i++) {
my $args=",";
for (my $j=0; $j<$i; $j++) {
$args.="a$j,";
}
chop($args);
print "#define ${moduleName}_DEBUG$i(H,f$args)\\\n";
print "\tjlog_fmt(H,JLOGT_DEBUG,MOD_${moduleName},-1,__FILE__,__FUNC__,__LINE__,f$args)\n";
}
print "\n";
print "#define ${moduleName}_ENTER(H)\\\n\tJLOG_ENTER0(H,MOD_${moduleName})\n";
for (my $i=0; $i<=10 ; $i++) {
my $args=",";
for (my $j=0; $j<$i; $j++) {
$args.="t$j,v$j,";
}
chop($args);
print "#define ${moduleName}_ENTER$i(H$args)\\\n\tJLOG_ENTER$i(H,MOD_${moduleName}$args)\n";
}
print "\n#endif /*${moduleName}_ERROR_H*/\n";
exit(0);
--- NEW FILE: par.errors ---
PARE_INVALID_ARGUMENT "invalid argument '%s'"
PARE_DIRECTORY_READ_FAILED "directory %s: does not exist"
PARE_BAD_MEM "memory failed"
PARE_READ_FAILED "file %s: read failed"
PARE_LIST_FILE_MISSING_INITIAL_SEPARATOR "%s missing start separator (%s)"
PARE_LIST_FILE_MISSING_FINAL_SEPARATOR "%s missing end separator (%s)"
PARE_FORMAT_ERROR "%s:%d: %s"
PARE_JNI_INVALID_OBJECT "invalid object: %s:%s"
|