Revision: 1155 Author: mwhapples@xxxxxxxxx Date: Mon Apr 28 17:08:29 2014 UTCLog: Changed logging callback system to set default when registering NULL for callback and to turn off one should use LOG_OFF
http://code.google.com/p/liblouis/source/detail?r=1155 Modified: /trunk/liblouis/compileTranslationTable.c /trunk/liblouis/liblouis.h.in /trunk/windows/include/liblouis.h ======================================= --- /trunk/liblouis/compileTranslationTable.c Mon Apr 28 09:25:53 2014 UTC +++ /trunk/liblouis/compileTranslationTable.c Mon Apr 28 17:08:29 2014 UTC @@ -5171,16 +5171,18 @@ static logcallback logCallbackFunction = defaultLogCallback; void EXPORT_CALL lou_registerLogCallback(logcallback callback) { + if (callback == 0) + logCallbackFunction = defaultLogCallback; logCallbackFunction = callback; } -static int logLevel = LOG_INFO; -void EXPORT_CALL lou_setLogLevel(int level) +static logLevels logLevel = LOG_INFO; +void EXPORT_CALL lou_setLogLevel(logLevels level) { logLevel = level; } -void EXPORT_CALL lou_log(int level, const char *format, ...) +void EXPORT_CALL lou_log(logLevels level, const char *format, ...) { if (format == NULL) return; @@ -5204,11 +5206,6 @@ } } } - -void EXPORT_CALL lou_setDefaultLogCallback() -{ - logCallbackFunction = defaultLogCallback; -} void logWidecharBuf(int level, const char *msg, widechar *wbuf, int wlen) { ======================================= --- /trunk/liblouis/liblouis.h.in Mon Apr 28 09:25:53 2014 UTC +++ /trunk/liblouis/liblouis.h.in Mon Apr 28 17:08:29 2014 UTC @@ -155,7 +155,9 @@ typedef void (*logcallback)(int level, const char *message); void EXPORT_CALL lou_registerLogCallback(logcallback callback); -/* Register logging callbacks */ +/* Register logging callbacks + * Set to NULL for default callback. + */ typedef enum { @@ -167,9 +169,9 @@ LOG_FATAL = 50000, LOG_OFF = 2147483647 } logLevels; - void EXPORT_CALL lou_setLogLevel(int level); - void EXPORT_CALL lou_setDefaultCallback(); - void EXPORT_CALL lou_log(int level, const char *format, ...); + void EXPORT_CALL lou_setLogLevel(logLevels level); + + void EXPORT_CALL lou_log(logLevels level, const char *format, ...); /* General log function for callback logging */ void EXPORT_CALL lou_free (); ======================================= --- /trunk/windows/include/liblouis.h Mon Apr 28 09:25:53 2014 UTC +++ /trunk/windows/include/liblouis.h Mon Apr 28 17:08:29 2014 UTC @@ -134,7 +134,9 @@ typedef void (*logcallback)(int level, const char *message); void EXPORT_CALL lou_registerLogCallback(logcallback callback); -/* Register logging callbacks */ +/* Register logging callbacks, + * Set to NULL for default callback. + */ typedef enum { @@ -146,9 +148,9 @@ LOG_FATAL = 50000, LOG_OFF = 2147483647 } logLevels; - void EXPORT_CALL lou_setLogLevel(int level); - void EXPORT_CALL lou_setDefaultLogCallback(); - void EXPORT_CALL lou_log(int level, const char *format, ...); + void EXPORT_CALL lou_setLogLevel(logLevels level); + + void EXPORT_CALL lou_log(logLevels level, const char *format, ...); /* General log function for callback logging */ void EXPORT_CALL lou_free (void); For a description of the software, to download it and links to project pages go to http://www.abilitiessoft.com