Deprecate Log class in Java example.

GitOrigin-RevId: 1ff3298befd963e27375c1e31fa5b22350396387
This commit is contained in:
levlam 2019-03-06 22:19:45 +03:00
parent 48077eb861
commit d2277e5995
3 changed files with 11 additions and 5 deletions

View File

@ -34,6 +34,6 @@ java '-Djava.library.path=.' org/drinkless/tdlib/example/Example
If you get "Could NOT find JNI ..." error from CMake, you need to specify to CMake path to the installed JDK, for example, "-DJAVA_HOME=/usr/lib/jvm/java-8-oracle/".
If you get java.lang.UnsatisfiedLinkError with "Can't find dependent libraries", you may also need to copy some dependent shared libraries to `bin/`.
If you get java.lang.UnsatisfiedLinkError with "Can't find dependent libraries", you may also need to copy some dependent shared OpenSSL and zlib libraries to `bin/`.
In case you compiled the example as 32-bit version, you may need to give -d32 parameter to Java.

View File

@ -7,12 +7,14 @@
package org.drinkless.tdlib;
/**
* Class for managing internal TDLib logging.
* Class used for managing internal TDLib logging.
* Use TdApi.*Log* methods instead.
*/
public final class Log {
/**
* Changes TDLib log verbosity.
*
* @deprecated As of TDLib 1.4.0 in favor of {@link TdApi.SetLogVerbosityLevel}, to be removed in the future.
* @param verbosityLevel New value of log verbosity level. Must be non-negative.
* Value 0 corresponds to fatal errors,
* value 1 corresponds to java.util.logging.Level.SEVERE,
@ -23,24 +25,29 @@ public final class Log {
* value greater than 5 can be used to enable even more logging.
* Default value of the log verbosity level is 5.
*/
@Deprecated
public static native void setVerbosityLevel(int verbosityLevel);
/**
* Sets file path for writing TDLib internal log. By default TDLib writes logs to the System.err.
* Use this method to write the log to a file instead.
*
* @deprecated As of TDLib 1.4.0 in favor of {@link TdApi.SetLogStream}, to be removed in the future.
* @param filePath Path to a file for writing TDLib internal log. Use an empty path to
* switch back to logging to the System.err.
* @return whether opening the log file succeeded.
*/
@Deprecated
public static native boolean setFilePath(String filePath);
/**
* Changes maximum size of TDLib log file.
*
* @deprecated As of TDLib 1.4.0 in favor of {@link TdApi.SetLogStream}, to be removed in the future.
* @param 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.
*/
@Deprecated
public static native void setMaxFileSize(long maxFileSize);
/**

View File

@ -7,7 +7,6 @@
package org.drinkless.tdlib.example;
import org.drinkless.tdlib.Client;
import org.drinkless.tdlib.Log;
import org.drinkless.tdlib.TdApi;
import java.io.IOError;
@ -285,8 +284,8 @@ public final class Example {
public static void main(String[] args) throws InterruptedException {
// disable TDLib log
Log.setVerbosityLevel(0);
if (!Log.setFilePath("tdlib.log")) {
Client.execute(new TdApi.SetLogVerbosityLevel(0));
if (Client.execute(new TdApi.SetLogStream(new TdApi.LogStreamFile("tdlib.log", 1 << 27))) instanceof TdApi.Error) {
throw new IOError(new IOException("Write access to the current directory is required"));
}