Use Td.Client.SetLogMessageCallback in UWP example.

This commit is contained in:
levlam 2021-05-20 03:51:33 +03:00
parent 58a12aca83
commit 3d28aaca62

View File

@ -29,6 +29,7 @@ namespace TdApp
Td.Client.Execute(new TdApi.SetLogVerbosityLevel(0));
Td.Client.Execute(new TdApi.SetLogStream(new TdApi.LogStreamFile(Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "log"), 1 << 27, false)));
Td.Client.SetLogMessageCallback(100, LogMessageCallback);
System.Threading.Tasks.Task.Run(() =>
{
@ -63,6 +64,14 @@ namespace TdApp
});
}
private void LogMessageCallback(int verbosity_level, String str)
{
if (verbosity_level < 0) {
return;
}
Print(verbosity_level + ": " + str);
}
private Td.Client _client;
private void AcceptCommand(String command)
@ -107,6 +116,12 @@ namespace TdApp
AcceptCommand(command);
_client.Send(new TdApi.CheckAuthenticationPassword(args[1]), _handler);
}
else if (command.StartsWith("alm"))
{
var args = command.Split(" ".ToCharArray(), 3);
AcceptCommand(command);
_client.Send(new TdApi.AddLogMessage(Int32.Parse(args[1]), args[2]), _handler);
}
else if (command.StartsWith("gco"))
{
var args = command.Split(" ".ToCharArray(), 2);