64 #ifndef REGIFY_UTIL_LOGGING_H
65 #define REGIFY_UTIL_LOGGING_H
100 #define RU_LOG_INFO 3
106 #define RU_LOG_VERB 4
113 #define RU_LOG_DBUG 5
300 bool cleaned,
bool threaded);
454 #define ruLog_(lvl, format, ...) ruMacStart { \
455 if(ruDoesLog(lvl)) { \
456 ruDoLog(lvl, __FILE__, __func__, __LINE__, format, __VA_ARGS__); \
465 #define ruCritLog(msg) ruLog_(RU_LOG_CRIT, "%s", msg)
472 #define ruCritLogf(fmt, ...) ruLog_(RU_LOG_CRIT, fmt, __VA_ARGS__)
478 #define ruWarnLog(msg) ruLog_(RU_LOG_WARN, "%s", msg)
485 #define ruWarnLogf(fmt, ...) ruLog_(RU_LOG_WARN, fmt, __VA_ARGS__)
491 #define ruInfoLog(msg) ruLog_(RU_LOG_INFO, "%s", msg)
498 #define ruInfoLogf(fmt, ...) ruLog_(RU_LOG_INFO, fmt, __VA_ARGS__)
504 #define ruVerbLog(msg) ruLog_(RU_LOG_VERB, "%s", msg)
511 #define ruVerbLogf(fmt, ...) ruLog_(RU_LOG_VERB, fmt, __VA_ARGS__)
517 #define ruDbgLog(msg) ruLog_(RU_LOG_DBUG, "%s", msg)
524 #define ruDbgLogf(fmt, ...) ruLog_(RU_LOG_DBUG, fmt, __VA_ARGS__)
531 #define ruDump8(msg, start) \
532 ruDbgLogf("%s @0x%x %02x %02x %02x %02x %02x %02x %02x %02x", msg, (start), \
533 (uint8_t)*(start), (uint8_t)*((start)+1), (uint8_t)*((start)+2), (uint8_t)*((start)+3), \
534 (uint8_t)*((start)+4), (uint8_t)*((start)+5), (uint8_t)*((start)+6), (uint8_t)*((start)+7))
541 #define ruDump16(msg, start) \
542 ruDbgLogf("%s @0x%x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x", msg, (start), \
543 (uint8_t)*(start), (uint8_t)*((start)+1), (uint8_t)*((start)+2), (uint8_t)*((start)+3), \
544 (uint8_t)*((start)+4), (uint8_t)*((start)+5), (uint8_t)*((start)+6), (uint8_t)*((start)+7), \
545 (uint8_t)*((start)+8), (uint8_t)*((start)+9), (uint8_t)*((start)+10), (uint8_t)*((start)+11), \
546 (uint8_t)*((start)+12), (uint8_t)*((start)+13), (uint8_t)*((start)+14), (uint8_t)*((start)+15))
void * ruCleaner
Definition: regify-util.h:690
RUAPI void ruDoLogV(uint32_t log_level, trans_chars filePath, trans_chars func, int32_t line, trans_chars format, va_list args)
Logs the given parameters if logging is set.
RUAPI void ruRawLog(uint32_t log_level, trans_chars msg)
Sends the given message as is to the current log sink.
RUAPI ruPreCtx ruPreCtxNew(void)
Creates a new pre logging context for use with ruPreLogSink.
RUAPI perm_ptr ruGetLogCtx(void)
Returns the ruSetLogger userData in use by the current logger.
RUAPI int32_t ruSinkWriteCb(ruSinkCtx rsc, ruWriteFunc writeCb)
Allow substituting fputs call with custom implementation.
int(* ruWriteFunc)(trans_chars buf, FILE *wh)
The type of function to pass to ruSinkWriteCb to substitute fputs.
Definition: logging.h:141
RUAPI void ruFileLogSink(perm_ptr rsc, uint32_t logLevel, trans_chars msg)
A log sink that logs into the filepath set in the given ruSinkCtx.
RUAPI uint32_t ruGetLogLevel(void)
Returns the currently set log level.
RUAPI ruPreCtx ruPreCtxFree(ruPreCtx rpc, bool flush)
Frees the given ruPreCtx.
RUAPI alloc_chars ruMakeLogMsgV(uint32_t log_level, trans_chars filePath, trans_chars func, int32_t line, trans_chars format, va_list args)
RUAPI void ruFlushLog(void)
Sends a NULL message with log level RU_LOG_CRIT to the current log sink, usually causing it to flush ...
RUAPI void ruLastLog(void)
Sends a NULL message with log level RU_LOG_NONE to the current log sink, usually causing it to close ...
void(* ruCloseFunc)(perm_ptr userData)
The type of function to pass to ruSinkCtxNew which will be called when ruFileLogSink has closed its l...
Definition: logging.h:136
RUAPI void ruLogDbg(trans_chars filePath, trans_chars func, int32_t line, trans_chars format,...)
Prints given parameters to stdout.
RUAPI void ruSetLogLevel(uint32_t logLevel)
Adjusts the current log level.
RUAPI int32_t ruSinkCtxPath(ruSinkCtx rsc, trans_chars filePath)
Allows changing the file path of the given ruSinkCtx.
RUAPI ruSinkCtx ruSinkCtxFree(ruSinkCtx rsc)
Frees the given ruSinkCtx after ruStopLogger has been called. This must not be called when the contex...
RUAPI void ruLoggerUnblock(void)
Unblocks any thread blocked on logging by removing the size limit of the log queue.
RUAPI void ruStopLogger(void)
Stop the current logger and flush the queue before returning.
ptr ruPreCtx
Opaque pointer to ruPreLogSink object.
Definition: logging.h:146
RUAPI char * ruMakeLogMsg(uint32_t log_level, trans_chars file, trans_chars func, int32_t line, trans_chars format,...)
RUAPI void ruDoLog(uint32_t log_level, trans_chars filePath, trans_chars func, int32_t line, trans_chars format,...)
Logs the given parameters if logging is set.
RUAPI bool ruDoesLog(uint32_t log_level)
Returns whether the given log level should log.
RUAPI void ruSetLogger(ruLogFunc logger, uint32_t logLevel, perm_ptr userData, bool cleaned, bool threaded)
Sets the global logging function for this process.
ptr ruSinkCtx
Opaque pointer to ruFileLogSink object.
Definition: logging.h:185
RUAPI void ruPreLogSink(perm_ptr rpc, uint32_t logLevel, trans_chars msg)
Pre logging sink to store log entries until a final log sink has been established.
void(* ruLogFunc)(perm_ptr userData, uint32_t logLevel, trans_chars msg)
The type of function to pass to ruSetLogger in order to hook up logging.
Definition: logging.h:129
RUAPI ruSinkCtx ruSinkCtxNew(trans_chars filePath, ruCloseFunc closeCb, perm_ptr closeCtx)
Creates a new context to use with ruFileLogSink.
RUAPI ruCleaner ruGetCleaner(void)
Public ruCleaner instance that is used by the logger when cleaning is enabled.
RUAPI void ruStdErrLogSink(perm_ptr udata, uint32_t logLevel, trans_chars msg)
A convenience logging implementation that logs to stderr.
const void * perm_ptr
A permanent pointer.
Definition: regify-util.h:277
const char * trans_chars
A transient NULL terminated string pointer.
Definition: regify-util.h:186
char * alloc_chars
An allocated NULL terminated string pointer.
Definition: regify-util.h:199
void * ptr
A generic pointer.
Definition: regify-util.h:304