Class DefaultFileHandler
java.lang.Object
java.util.logging.Handler
java.util.logging.StreamHandler
java.util.logging.FileHandler
eu.cloudnetservice.common.log.defaults.DefaultFileHandler
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 Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateDefaultFileHandler(@NonNull String pattern, int limit, int count, boolean append) Constructs a new default file handler instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull DefaultFileHandlernewInstance(@NonNull String pattern, boolean append) Constructs a new file handler using the given file name pattern and append settings.static @NonNull DefaultFileHandlernewInstance(@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.static @NonNull DefaultFileHandlernewInstance(@NonNull Path pattern, boolean append) Constructs a new file handler using the given file name pattern and append settings.static @NonNull DefaultFileHandlernewInstance(@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.withFormatter(@NonNull Formatter formatter) Sets the formatter of this handler and returns the same instance as used to call the method, for chaining.Methods inherited from class java.util.logging.FileHandler
close, publishMethods inherited from class java.util.logging.StreamHandler
flush, isLoggable, setEncoding, setOutputStreamMethods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, reportError, setErrorManager, setFilter, setFormatter, setLevel
-
Field Details
-
DEFAULT_COUNT
public static final int DEFAULT_COUNT- See Also:
-
DEFAULT_LIMIT
public static final int DEFAULT_LIMIT- See Also:
-
-
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 of4194304bytes 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 of4194304bytes 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
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.
-