Class LoggyFile

java.lang.Object
fr.diskmth.loggy.Loggable
fr.diskmth.loggy.LoggyFile

public class LoggyFile extends Loggable
LoggyFile is a class that extends the java.util.logging.Handler class and is used to handle logging messages to a file.
Since:
Loggy 1.0
  • Field Details

    • path

      protected final Path path
    • fileHandler

      protected FileHandler fileHandler
  • Constructor Details

    • LoggyFile

      public LoggyFile(String path, LoggyFormatter formatter)
      Constructs a new LoggyFile object with the specified path and formatter.
      Parameters:
      path - the path to the log file
      formatter - the formatter to use for formatting log messages
    • LoggyFile

      public LoggyFile(String path)
      Constructs a new LoggyFile object with the specified path and the default formatter.
      Parameters:
      path - the path to the log file
  • Method Details

    • init

      public LoggyFile init()
      Initializes the log file by creating the directory if it doesn't exist, setting up the file handler, and clearing any existing logs in the directory.
      Returns:
      this LoggyFile object
    • close

      public LoggyFile close()
      Closes the file handler and clears any existing logs in the directory.
      Returns:
      this LoggyFile object
    • clearLogDir

      public void clearLogDir()
      Clears any empty log files in the log directory.
    • getPath

      public Path getPath()
      Returns the path to the log file.
      Returns:
      the path to the log file
    • getFileHandler

      public FileHandler getFileHandler()
      Returns the file handler for this LoggyFile object.
      Returns:
      the file handler for this LoggyFile object
    • getDir

      public String getDir()
      Returns the directory containing the log file.
      Returns:
      the directory containing the log file
    • getFileName

      public String getFileName()
      Returns the filename of the log file.
      Returns:
      the filename of the log file