Class SimpleWriter

    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleWriter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void appendLog​(java.lang.String log)
      Append the log to the end of the opened log file, normally an extra line separator is needed.
      boolean close()
      Make sure the opened log file is closed, normally called before switching the log file.
      java.io.File getOpenedFile()
      Get the opened log file.
      java.lang.String getOpenedFileName()
      Get the name of opened log file.
      boolean isOpened()
      Whether a log file is successfully opened in previous Writer.open(File).
      void onNewFileCreated​(java.io.File file)
      Called after a log file is newly created.
      boolean open​(java.io.File file)
      Open a specific log file for future writing, if it doesn't exist yet, just create it.
      • Methods inherited from class java.lang.Object

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

      • SimpleWriter

        public SimpleWriter()
    • Method Detail

      • open

        public boolean open​(java.io.File file)
        Description copied from class: Writer
        Open a specific log file for future writing, if it doesn't exist yet, just create it.
        Specified by:
        open in class Writer
        Parameters:
        file - the specific log file, may not exist
        Returns:
        true if the log file is successfully opened, false otherwise
      • isOpened

        public boolean isOpened()
        Description copied from class: Writer
        Whether a log file is successfully opened in previous Writer.open(File).
        Specified by:
        isOpened in class Writer
        Returns:
        true if log file is opened, false otherwise
      • getOpenedFile

        public java.io.File getOpenedFile()
        Description copied from class: Writer
        Get the opened log file.
        Specified by:
        getOpenedFile in class Writer
        Returns:
        the opened log file, or null if log file not opened
      • getOpenedFileName

        public java.lang.String getOpenedFileName()
        Description copied from class: Writer
        Get the name of opened log file.
        Specified by:
        getOpenedFileName in class Writer
        Returns:
        the name of opened log file, or null if log file not opened
      • onNewFileCreated

        public void onNewFileCreated​(java.io.File file)
        Called after a log file is newly created.

        You can do some initialization work to the new file, such as calling appendLog(String) to add a file header.

        Called in worker thread.

        Parameters:
        file - the newly create log file
      • appendLog

        public void appendLog​(java.lang.String log)
        Description copied from class: Writer
        Append the log to the end of the opened log file, normally an extra line separator is needed.
        Specified by:
        appendLog in class Writer
        Parameters:
        log - the log to append
      • close

        public boolean close()
        Description copied from class: Writer
        Make sure the opened log file is closed, normally called before switching the log file.
        Specified by:
        close in class Writer
        Returns:
        true if the log file is successfully closed, false otherwise