Class DefaultFileHandler


public final class DefaultFileHandler extends FileHandler
Represents the default file handler implementation of CloudNet, allowing more precise configuration of the resulting log files which are created and then written to.
Since:
4.0
  • Field Details

  • Constructor Details

    • DefaultFileHandler

      private DefaultFileHandler(@NonNull @NonNull String pattern, int limit, int count, boolean append) throws IOException
      Constructs a new default file handler instance.
      Parameters:
      pattern - the pattern for naming the output files.
      limit - the maximum number of bytes to write to a log file.
      count - the amount files to create before re-using the first one.
      append - if the handler should append to the selected log file.
      Throws:
      IOException - if an I/O error occurs while opening the log files.
      NullPointerException - if the given naming pattern is null.
      IllegalArgumentException - if pattern is empty, limit < 0 or count < 1.
  • Method Details

    • newInstance

      @NonNull public static @NonNull DefaultFileHandler newInstance(@NonNull @NonNull String pattern, boolean append)
      Constructs a new file handler using the given file name pattern and append settings. This method uses a maximum file size of 4194304 bytes and a maximum file count of 8.
      Parameters:
      pattern - the pattern for naming the output files.
      append - if the handler should append to the selected log file.
      Returns:
      the created file handler.
      Throws:
      IllegalStateException - if an I/O error occurs while opening the log files.
      NullPointerException - if the given naming pattern is null.
      IllegalArgumentException - if pattern is empty, limit < 0 or count < 1.
    • newInstance

      @NonNull public static @NonNull DefaultFileHandler newInstance(@NonNull @NonNull String pattern, int limit, int count, boolean append)
      Constructs a new file handler using the given file name pattern, limit, count and append settings.
      Parameters:
      pattern - the pattern for naming the output files.
      limit - the maximum number of bytes to write to a log file.
      count - the amount files to create before re-using the first one.
      append - if the handler should append to the selected log file.
      Returns:
      the created file handler.
      Throws:
      IllegalStateException - if an I/O error occurs while opening the log files.
      NullPointerException - if the given naming pattern is null.
      IllegalArgumentException - if pattern is empty, limit < 0 or count < 1.
    • newInstance

      @NonNull public static @NonNull DefaultFileHandler newInstance(@NonNull @NonNull Path pattern, boolean append)
      Constructs a new file handler using the given file name pattern and append settings. This method uses a maximum file size of 4194304 bytes and a maximum file count of 8.
      Parameters:
      pattern - the pattern for naming the output files.
      append - if the handler should append to the selected log file.
      Returns:
      the created file handler.
      Throws:
      IllegalStateException - if an I/O error occurs while opening the log files.
      NullPointerException - if the given naming pattern is null.
      IllegalArgumentException - if pattern is empty, limit < 0 or count < 1.
    • newInstance

      @NonNull public static @NonNull DefaultFileHandler newInstance(@NonNull @NonNull Path pattern, int limit, int count, boolean append)
      Constructs a new file handler using the given file name pattern, limit, count and append settings.
      Parameters:
      pattern - the pattern for naming the output files.
      limit - the maximum number of bytes to write to a log file.
      count - the amount files to create before re-using the first one.
      append - if the handler should append to the selected log file.
      Returns:
      the created file handler.
      Throws:
      IllegalStateException - if an I/O error occurs while opening the log files.
      NullPointerException - if the given naming pattern is null.
      IllegalArgumentException - if pattern is empty, limit < 0 or count < 1.
    • withFormatter

      @NonNull public @NonNull DefaultFileHandler withFormatter(@NonNull @NonNull Formatter formatter)
      Sets the formatter of this handler and returns the same instance as used to call the method, for chaining.
      Parameters:
      formatter - the formatter to use for this handler.
      Returns:
      the same instance as used to call the method, for chaining.
      Throws:
      NullPointerException - if the given formatter is null.