Deprecate Log methods in C++ and JSON interfaces.

GitOrigin-RevId: d327c2400432b309d52ed23b04e47ba6adb46682
This commit is contained in:
levlam 2019-03-07 01:28:35 +03:00
parent d2277e5995
commit 65f0f78574
4 changed files with 17 additions and 5 deletions

View File

@ -5,7 +5,6 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include <td/telegram/Client.h>
#include <td/telegram/Log.h>
#include <td/telegram/td_api.h>
#include <td/telegram/td_api.hpp>
@ -54,7 +53,7 @@ namespace td_api = td::td_api;
class TdExample {
public:
TdExample() {
td::Log::set_verbosity_level(1);
td::Client::execute({0, td_api::make_object<td_api::setLogVerbosityLevel>(1)});
client_ = std::make_unique<td::Client>();
}

View File

@ -12,6 +12,9 @@
// the main event cycle, which should be essentially the same for all languages.
int main() {
// disable TDLib logging
td_json_client_execute(nullptr, "{\"@type\":\"setLogVerbosityLevel\", \"new_verbosity_level\":0}");
void *client = td_json_client_create();
// somehow share the client with other threads, which will be able to send requests via td_json_client_send

View File

@ -20,6 +20,8 @@ namespace td {
/**
* Interface for managing the internal logging of TDLib.
* By default TDLib writes logs to stderr or an OS specific log and uses a verbosity level of 5.
* These functions are deprecated since TDLib 1.4.0 in favor of the td::td_api::setLogVerbosityLevel,
* td::td_api::setLogStream and other synchronous requests for managing the intrenal TDLib logging.
*/
class Log {
public:
@ -28,6 +30,7 @@ class Log {
* By default TDLib writes logs to stderr or an OS specific log.
* Use this method to write the log to a file instead.
*
* \deprecated Use synchronous td::td_api::setLogStream request instead.
* \param[in] file_path Path to a file where the internal TDLib log will be written. Use an empty path to
* switch back to the default logging behaviour.
* \return True on success, or false otherwise, i.e. if the file can't be opened for writing.
@ -38,6 +41,7 @@ class Log {
* Sets maximum size of the file to where the internal TDLib log is written before the file will be auto-rotated.
* Unused if log is not written to a file. Defaults to 10 MB.
*
* \deprecated Use synchronous td::td_api::setLogStream request instead.
* \param[in] max_file_size Maximum size of the file to where the internal TDLib log is written before the file
* will be auto-rotated. Should be positive.
*/
@ -47,6 +51,7 @@ class Log {
* Sets the verbosity level of the internal logging of TDLib.
* By default the TDLib uses a verbosity level of 5 for logging.
*
* \deprecated Use synchronous td::td_api::setLogVerbosityLevel request instead.
* \param[in] new_verbosity_level New value of the verbosity level for logging.
* Value 0 corresponds to fatal errors,
* value 1 corresponds to errors,

View File

@ -10,6 +10,8 @@
* \file
* C interface for managing the internal logging of TDLib.
* By default TDLib writes logs to stderr or an OS specific log and uses a verbosity level of 5.
* These functions are deprecated since TDLib 1.4.0 in favor of the setLogVerbosityLevel, setLogStream and
* other synchronous requests for managing the intrenal TDLib logging.
*/
#include "td/telegram/tdjson_export.h"
@ -23,25 +25,28 @@ extern "C" {
* By default TDLib writes logs to stderr or an OS specific log.
* Use this method to write the log to a file instead.
*
* \deprecated Use synchronous setLogStream request instead.
* \param[in] file_path Null-terminated path to a file where the internal TDLib log will be written.
* Use an empty path to switch back to the default logging behaviour.
* \return True 1 on success, or 0 otherwise, i.e. if the file can't be opened for writing.
*/
TDJSON_EXPORT int td_set_log_file_path(const char *file_path);
TDJSON_DEPRECATED_EXPORT int td_set_log_file_path(const char *file_path);
/**
* Sets maximum size of the file to where the internal TDLib log is written before the file will be auto-rotated.
* Unused if log is not written to a file. Defaults to 10 MB.
*
* \deprecated Use synchronous setLogStream request instead.
* \param[in] max_file_size Maximum size of the file to where the internal TDLib log is written before the file
* will be auto-rotated. Should be positive.
*/
TDJSON_EXPORT void td_set_log_max_file_size(long long max_file_size);
TDJSON_DEPRECATED_EXPORT void td_set_log_max_file_size(long long max_file_size);
/**
* Sets the verbosity level of the internal logging of TDLib.
* By default the TDLib uses a log verbosity level of 5.
*
* \deprecated Use synchronous setLogVerbosityLevel request instead.
* \param[in] new_verbosity_level New value of logging verbosity level.
* Value 0 corresponds to fatal errors,
* value 1 corresponds to errors,
@ -51,7 +56,7 @@ TDJSON_EXPORT void td_set_log_max_file_size(long long max_file_size);
* value 5 corresponds to verbose debug,
* value greater than 5 and up to 1024 can be used to enable even more logging.
*/
TDJSON_EXPORT void td_set_log_verbosity_level(int new_verbosity_level);
TDJSON_DEPRECATED_EXPORT void td_set_log_verbosity_level(int new_verbosity_level);
/**
* A type of callback function that will be called when a fatal error happens.