Deprecate Log in .NET native binding.

GitOrigin-RevId: 08d3321d68a7406dd0e2a5f5877619d9e864ba1e
This commit is contained in:
levlam 2019-02-24 19:17:36 +03:00
parent 3226e859ad
commit 6af95d721d
4 changed files with 12 additions and 5 deletions

View File

@ -206,8 +206,8 @@ namespace TdExample
static void Main() static void Main()
{ {
// disable TDLib log // disable TDLib log
Td.Log.SetVerbosityLevel(0); Td.Client.Execute(new TdApi.SetLogVerbosityLevel(0));
if (!Td.Log.SetFilePath("tdlib.log")) if (Td.Client.Execute(new TdApi.SetLogStream(new TdApi.LogStreamFile("tdlib.log", 1 << 27))) is TdApi.Error)
{ {
throw new System.IO.IOException("Write access to the current directory is required"); throw new System.IO.IOException("Write access to the current directory is required");
} }

View File

@ -27,8 +27,8 @@ namespace TdApp
Items = new System.Collections.ObjectModel.ObservableCollection<string>(); Items = new System.Collections.ObjectModel.ObservableCollection<string>();
_handler = new MyClientResultHandler(this); _handler = new MyClientResultHandler(this);
Td.Log.SetFilePath(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "log")); Td.Client.Execute(new TdApi.SetLogVerbosityLevel(0));
Td.Log.SetVerbosityLevel(0); Td.Client.Execute(new TdApi.SetLogStream(new TdApi.LogStreamFile(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "log"), 1 << 27)));
System.Threading.Tasks.Task.Run(() => System.Threading.Tasks.Task.Run(() =>
{ {
@ -118,7 +118,7 @@ namespace TdApp
{ {
var args = command.Split(" ".ToCharArray(), 2); var args = command.Split(" ".ToCharArray(), 2);
AcceptCommand(command); AcceptCommand(command);
_client.Send(new TdApi.DownloadFile(Int32.Parse(args[1]), 1), _handler); _client.Send(new TdApi.DownloadFile(Int32.Parse(args[1]), 1, 0, 0), _handler);
} }
else if (command.StartsWith("bench")) else if (command.StartsWith("bench"))
{ {

View File

@ -18,6 +18,7 @@ using namespace CxCli;
/// <summary> /// <summary>
/// Class for managing internal TDLib logging. /// Class for managing internal TDLib logging.
/// </summary> /// </summary>
[DEPRECATED_ATTRIBUTE("Telegram.Td.Log class is deprecated, please use Telegram.Td.Api.*Log* requests instead.")]
public ref class Log sealed { public ref class Log sealed {
public: public:
/// <summary> /// <summary>
@ -27,6 +28,7 @@ public:
/// Value 0 means FATAL, value 1 means ERROR, value 2 means WARNING, value 3 means INFO, value 4 means DEBUG, /// Value 0 means FATAL, value 1 means ERROR, value 2 means WARNING, value 3 means INFO, value 4 means DEBUG,
/// value greater than 4 can be used to enable even more logging. /// value greater than 4 can be used to enable even more logging.
/// Default value of the log verbosity level is 5.</param> /// Default value of the log verbosity level is 5.</param>
[DEPRECATED_ATTRIBUTE("SetVerbosityLevel is deprecated, please use Telegram.Td.Api.SetLogVerbosityLevel request instead.")]
static void SetVerbosityLevel(int verbosityLevel) { static void SetVerbosityLevel(int verbosityLevel) {
::td::Log::set_verbosity_level(verbosityLevel); ::td::Log::set_verbosity_level(verbosityLevel);
} }
@ -38,6 +40,7 @@ public:
/// <param name="filePath">Path to a file for writing TDLib internal log. Use an empty path to switch back to logging /// <param name="filePath">Path to a file for writing TDLib internal log. Use an empty path to switch back to logging
/// to the System.err.</param> /// to the System.err.</param>
/// <returns>Returns whether opening the log file succeeded.</returns> /// <returns>Returns whether opening the log file succeeded.</returns>
[DEPRECATED_ATTRIBUTE("SetFilePath is deprecated, please use Telegram.Td.Api.SetLogStream request instead.")]
static bool SetFilePath(String^ filePath) { static bool SetFilePath(String^ filePath) {
return ::td::Log::set_file_path(string_to_unmanaged(filePath)); return ::td::Log::set_file_path(string_to_unmanaged(filePath));
} }
@ -47,6 +50,7 @@ public:
/// </summary> /// </summary>
/// <param name="maxFileSize">Maximum size of the file to where the internal TDLib log is written /// <param name="maxFileSize">Maximum size of the file to where the internal TDLib log is written
/// before the file will be auto-rotated. Must be positive. Defaults to 10 MB.</param> /// before the file will be auto-rotated. Must be positive. Defaults to 10 MB.</param>
[DEPRECATED_ATTRIBUTE("SetMaxFileSize is deprecated, please use Telegram.Td.Api.SetLogStream request instead.")]
static void SetMaxFileSize(std::int64_t maxFileSize) { static void SetMaxFileSize(std::int64_t maxFileSize) {
::td::Log::set_max_file_size(maxFileSize); ::td::Log::set_max_file_size(maxFileSize);
} }

View File

@ -23,6 +23,8 @@
#define REF_NEW ref new #define REF_NEW ref new
#define CLRCALL #define CLRCALL
#define DEPRECATED_ATTRIBUTE(message) ::Windows::Foundation::Metadata::Deprecated(message,\
::Windows::Foundation::Metadata::DeprecationType::Deprecate, 0x0)
namespace CxCli { namespace CxCli {
@ -90,6 +92,7 @@ inline String^ string_from_unmanaged(const std::string &from) {
#define REF_NEW gcnew #define REF_NEW gcnew
#define CLRCALL __clrcall #define CLRCALL __clrcall
#define DEPRECATED_ATTRIBUTE(message) System::ObsoleteAttribute(message)
namespace CxCli { namespace CxCli {