diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-19 13:07:45 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-08-27 01:16:14 +0100 |
commit | 13ae9e9a93a1c02fad9475002c0391b86b7ad7bb (patch) | |
tree | a9575d3582c4f40e051c93ae18dded03fdddc432 /other/apidsl/tox.in.h | |
parent | 1f25fc0ae417bfc47dea4966cb5e43689aa88d5c (diff) |
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.
Diffstat (limited to 'other/apidsl/tox.in.h')
-rw-r--r-- | other/apidsl/tox.in.h | 51 |
1 files changed, 51 insertions, 0 deletions
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) { | |||
609 | void kill(); | 609 | void kill(); |
610 | 610 | ||
611 | 611 | ||
612 | /** | ||
613 | * Severity level of log messages. | ||
614 | */ | ||
615 | enum class LOG_LEVEL { | ||
616 | /** | ||
617 | * Very detailed traces including all network activity. | ||
618 | */ | ||
619 | LOG_TRACE, | ||
620 | /** | ||
621 | * Debug messages such as which port we bind to. | ||
622 | */ | ||
623 | LOG_DEBUG, | ||
624 | /** | ||
625 | * Informational log messages such as video call status changes. | ||
626 | */ | ||
627 | LOG_INFO, | ||
628 | /** | ||
629 | * Warnings about internal inconsistency or logic errors. | ||
630 | */ | ||
631 | LOG_WARNING, | ||
632 | /** | ||
633 | * Severe unexpected errors caused by external or internal inconsistency. | ||
634 | */ | ||
635 | LOG_ERROR, | ||
636 | } | ||
637 | |||
638 | /** | ||
639 | * This event is triggered when the toxcore library logs an internal message. | ||
640 | * This is mostly useful for debugging. This callback can be called from any | ||
641 | * function, not just $iterate. This means the user data lifetime must at | ||
642 | * least extend between registering and unregistering it or $kill. | ||
643 | * | ||
644 | * Other toxcore modules such as toxav may concurrently call this callback at | ||
645 | * any time. Thus, user code must make sure it is equipped to handle concurrent | ||
646 | * execution, e.g. by employing appropriate mutex locking. The callback | ||
647 | * registration function must not be called during execution of any other Tox | ||
648 | * library function (toxcore or toxav). | ||
649 | */ | ||
650 | event log { | ||
651 | /** | ||
652 | * @param level The severity of the log message. | ||
653 | * @param file The source file from which the message originated. | ||
654 | * @param line The source line from which the message originated. | ||
655 | * @param func The function from which the message originated. | ||
656 | * @param message The log message. | ||
657 | */ | ||
658 | typedef void(LOG_LEVEL level, string file, uint32_t line, string func, | ||
659 | string message); | ||
660 | } | ||
661 | |||
662 | |||
612 | uint8_t[size] savedata { | 663 | uint8_t[size] savedata { |
613 | /** | 664 | /** |
614 | * Calculates the number of bytes required to store the tox instance with | 665 | * Calculates the number of bytes required to store the tox instance with |