diff --git a/td/telegram/Client.h b/td/telegram/Client.h
index 5eaf480d2..b61dc60d9 100644
--- a/td/telegram/Client.h
+++ b/td/telegram/Client.h
@@ -241,15 +241,15 @@ class ClientManager final {
/**
* A type of callback function that will be called when a message is added to the internal TDLib log.
*
- * \param verbosity_level Log verbosity level with which the message was added.
- * \param message Null-terminated string with the logged message.
+ * \param verbosity_level Log verbosity level with which the message was added. If 0, then TDLib will crash
+ * as soon as the callback returns.
+ * \param message Null-terminated string with the message added to the log.
*/
using LogMessageCallbackPtr = void (*)(int verbosity_level, const char *message);
/**
* Sets the callback that will be called when a message is added to the internal TDLib log.
* None of the TDLib methods can be called from the callback.
- * If message verbosity level is 0, then TDLib will crash as soon as callback returns.
* By default the callback is not set.
*
* \param[in] max_verbosity_level Maximum verbosity level of messages for which the callback will be called.
diff --git a/td/telegram/ClientDotNet.cpp b/td/telegram/ClientDotNet.cpp
index 72a4c229a..56cb0be31 100644
--- a/td/telegram/ClientDotNet.cpp
+++ b/td/telegram/ClientDotNet.cpp
@@ -6,7 +6,6 @@
//
#pragma managed(push, off)
#include "td/telegram/Client.h"
-#include "td/telegram/Log.h"
#pragma managed(pop)
#include "td/telegram/TdDotNetApi.h"
@@ -23,10 +22,12 @@ namespace Td {
using namespace CxCli;
///
-/// A type of callback function that will be called when a fatal error happens.
+/// A type of callback function that will be called when a message is added to the internal TDLib log.
///
-/// Null-terminated string with a description of a happened fatal error.
-public delegate void FatalErrorCallback(String^ errorMessage);
+/// Log verbosity level with which the message was added. If 0,
+/// then TDLib will crash as soon as the callback returns.
+/// Null-terminated string with the message added to the log.
+public delegate void LogMessageCallback(int verbosityLevel, String^ message);
///
/// Interface for handler for results of queries to TDLib and incoming updates from TDLib.
@@ -113,17 +114,20 @@ public:
}
///
- /// Sets the callback that will be called when a fatal error happens.
+ /// Sets the callback that will be called when a message is added to the internal TDLib log.
+ /// None of the TDLib methods can be called from the callback.
///
- /// Callback that will be called when a fatal error happens. Pass null to remove the callback.
- static void SetFatalErrorCallback(FatalErrorCallback^ callback) {
+ /// Maximum verbosity level of messages for which the callback will be called.
+ /// Callback that will be called when a message is added to the internal TDLib log.
+ /// Pass null to remove the callback.
+ static void SetLogMessageCallback(std::int32_t max_verbosity_level, LogMessageCallback^ callback) {
std::lock_guard lock(logMutex);
if (callback == nullptr) {
- ::td::Log::set_fatal_error_callback(nullptr);
- fatalErrorCallback = nullptr;
+ ::td::ClientManager::set_log_message_callback(max_verbosity_level, nullptr);
+ logMessageCallback = nullptr;
} else {
- fatalErrorCallback = callback;
- ::td::Log::set_fatal_error_callback(FatalErrorCallbackWrapper);
+ logMessageCallback = callback;
+ ::td::ClientManager::set_log_message_callback(max_verbosity_level, LogMessageCallbackWrapper);
}
}
@@ -151,16 +155,18 @@ private:
}
static std::mutex logMutex;
- static FatalErrorCallback^ fatalErrorCallback;
+ static LogMessageCallback^ logMessageCallback;
- static void FatalErrorCallbackWrapper(const char* message) {
- CHECK(fatalErrorCallback != nullptr);
- fatalErrorCallback(string_from_unmanaged(message));
+ static void LogMessageCallbackWrapper(int verbosity_level, const char *message) {
+ auto callback = logMessageCallback;
+ if (callback != nullptr) {
+ callback(verbosity_level, string_from_unmanaged(message));
+ }
}
};
std::mutex Client::logMutex;
-FatalErrorCallback^ Client::fatalErrorCallback;
+LogMessageCallback^ Client::logMessageCallback;
} // namespace Td
} // namespace Telegram