Class Log


  • public class Log
    extends java.lang.Object
    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.
    • Constructor Summary

      Constructors 
      Constructor Description
      Log()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void setFatalErrorCallback​(FatalErrorCallbackPtr fatalErrorCallback)
      Sets the callback that will be called when a fatal error happens.
      static boolean setFilePath​(java.lang.String filePath)
      Sets the path to the file to where the internal TDLib log will be written.
      static void setMaxFileSize​(long maxFileSize)
      Sets maximum size of the file to where the internal TDLib log is written before the file will be auto-rotated.
      static void setVerbosityLevel​(int verbosityLevel)
      Sets the verbosity level of the internal logging of TDLib.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Log

        public Log()
    • Method Detail

      • setFilePath

        public static boolean setFilePath​(java.lang.String filePath)
        Sets the path to the file to where the internal TDLib log will be written. By default TDLib writes logs to stderr or an OS specific log. Use this method to write the log to a file instead.
        Parameters:
        filePath - Path to a file where the internal TDLib log will be written. Use an empty path to switch back to the default logging behaviour.
        Returns:
        True on success, or false otherwise, i.e. if the file can't be opened for writing.
      • setMaxFileSize

        public static void setMaxFileSize​(long maxFileSize)
        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.
        Parameters:
        maxFileSize - Maximum size of the file to where the internal TDLib log is written before the file will be auto-rotated. Should be positive.
      • setVerbosityLevel

        public static void setVerbosityLevel​(int verbosityLevel)
        Sets the verbosity level of the internal logging of TDLib. By default the TDLib uses a verbosity level of 5 for logging.
        Parameters:
        verbosityLevel - New value of the verbosity level for logging. Value 0 corresponds to fatal errors, value 1 corresponds to errors, value 2 corresponds to warnings and debug warnings, value 3 corresponds to informational, value 4 corresponds to debug, value 5 corresponds to verbose debug, value greater than 5 and up to 1024 can be used to enable even more logging.
      • setFatalErrorCallback

        public static void setFatalErrorCallback​(FatalErrorCallbackPtr fatalErrorCallback)
        Sets the callback that will be called when a fatal error happens. None of the TDLib methods can be called from the callback. The TDLib will crash as soon as callback returns. By default the callback set to print in stderr.
        Parameters:
        fatalErrorCallback - Callback that will be called when a fatal error happens. Pass null to restore default callback.