From 13ae9e9a93a1c02fad9475002c0391b86b7ad7bb Mon Sep 17 00:00:00 2001 From: iphydf Date: Fri, 19 Aug 2016 13:07:45 +0100 Subject: Move logging to a callback. This removes the global logger (which by the way was deleted when the first tox was killed, so other toxes would then stop logging). Various bits of the code now carry a logger or pass it around. It's a bit less transparent now, but now there is no need to have a global logger, and clients can decide what to log and where. --- other/apidsl/tox.in.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'other/apidsl') diff --git a/other/apidsl/tox.in.h b/other/apidsl/tox.in.h index 4c9c4972..074897ad 100644 --- a/other/apidsl/tox.in.h +++ b/other/apidsl/tox.in.h @@ -609,6 +609,57 @@ static this new(const options_t *options) { void kill(); +/** + * Severity level of log messages. + */ +enum class LOG_LEVEL { + /** + * Very detailed traces including all network activity. + */ + LOG_TRACE, + /** + * Debug messages such as which port we bind to. + */ + LOG_DEBUG, + /** + * Informational log messages such as video call status changes. + */ + LOG_INFO, + /** + * Warnings about internal inconsistency or logic errors. + */ + LOG_WARNING, + /** + * Severe unexpected errors caused by external or internal inconsistency. + */ + LOG_ERROR, +} + +/** + * This event is triggered when the toxcore library logs an internal message. + * This is mostly useful for debugging. This callback can be called from any + * function, not just $iterate. This means the user data lifetime must at + * least extend between registering and unregistering it or $kill. + * + * Other toxcore modules such as toxav may concurrently call this callback at + * any time. Thus, user code must make sure it is equipped to handle concurrent + * execution, e.g. by employing appropriate mutex locking. The callback + * registration function must not be called during execution of any other Tox + * library function (toxcore or toxav). + */ +event log { + /** + * @param level The severity of the log message. + * @param file The source file from which the message originated. + * @param line The source line from which the message originated. + * @param func The function from which the message originated. + * @param message The log message. + */ + typedef void(LOG_LEVEL level, string file, uint32_t line, string func, + string message); +} + + uint8_t[size] savedata { /** * Calculates the number of bytes required to store the tox instance with -- cgit v1.2.3