error logger headaches

This commit is contained in:
2026-03-11 14:58:11 -04:00
parent 0003a9d6d2
commit bb7579f7b0
4 changed files with 52 additions and 0 deletions

Binary file not shown.

View File

@ -25,6 +25,28 @@ static const int amsmathutil25_maxthreads = 50;
static const int amsmathutil25_threadpsz = 5000;
//Global Changeable Error Logger //
//Using accessor pattern
//pointer to function of signature void errorlogger(const char *errmsg, int errcode, void *errglobal);
extern void (*amsmathutil25_errlogger)(const char *, int, void *);
extern void* amsmathutil25_errglobal;
typedef void (*amsmathutil25_errloggerptr_t)(const char *, int, void *);
amsmathutil25_errloggerptr_t amsmathutil25_get_errlogger(); //call this to get the error logger to log errors
// //the other way to do this
// // return type "pointer to function(const char*, int, void*) returning void"
// void (*amsmathutil25_get_errlogger(void))(const char *, int, void *);
// //not exactly clear....
void amsmathutil25_set_errlogger(
void(*errloggerpointer)(const char *, int, void *),
void* errglobal
);
//End Error Logger
};
//Library subsections

View File

@ -0,0 +1,30 @@
#include <amsmathutil25/amsmathutil25.hpp>
namespace ams
{
void amsmathutil25_default_errlogger(
const char *msg,
int code,
void *)
{
fprintf(stderr,"%s, %d\n",msg,code);
return;
}
amsmathutil25_errloggerptr_t amsmathutil25_get_errlogger()
{
if(amsmathutil25_errlogger==NULL)
{
amsmathutil25_errlogger = amsmathutil25_default_errlogger;
}
return amsmathutil25_errlogger;
}
void amsmathutil25_set_errlogger(void(*errloggerpointer)(const char *, int, void *),void *errglobal)
{
amsmathutil25_errglobal = errglobal;
amsmathutil25_errlogger = errloggerpointer;
}
};