<commit_before>package com.nhl.bootique.logback.appender;

import java.util.Objects;

import com.fasterxml.jackson.annotation.JsonTypeName;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.FileAppender;
import ch.qos.logback.core.encoder.LayoutWrappingEncoder;

/**
 * @since 0.8
 */
@JsonTypeName("file")
public class FileAppenderFactory extends AppenderFactory {

	private String file;

	public void setFile(String file) {
		this.file = file;
	}

	@Override
	public Appender<ILoggingEvent> createAppender(LoggerContext context) {
		FileAppender<ILoggingEvent> appender = new FileAppender<>();
		appender.setFile(Objects.requireNonNull(file));<commit_msg> Log file rotation configuration #7 <commit_after>package com.nhl.bootique.logback.appender;

import java.util.Objects;

import com.fasterxml.jackson.annotation.JsonTypeName;

import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.Appender;
import ch.qos.logback.core.FileAppender;
import ch.qos.logback.core.encoder.LayoutWrappingEncoder;

/**
 * A configuration object that sets up a file appender in Logback, potentially
 * with support for rotation, etc.
 * 
 * @since 0.8
 */
@JsonTypeName("file")
public class FileAppenderFactory extends AppenderFactory {

	private String file;
	private boolean rotate;
	private String maxFileSize;
	private int maxFiles;
	private String maxTotalFileSize;

	/**
	 * Sets a filename or a filename pattern for the log file. If "rotate" is
	 * true, the filename can be a pattern per <a href=
	 * "http://logback.qos.ch/manual/appenders.html#RollingFileAppender">Logback
	 * documentation</a> that determines time-based rotation interval.
	 * Additional settings on this factory allow to also cap individual and
	 * total files sizes and how many total log files can be kept.
	 * 
	 * @param file
	 *            a filename or a filename pattern for the log file.
	 */
	public void setFile(String file) {
		this.file = file;
	}

	/**
	 * Enables or disables file rotation. Default is "false".
	 * 
	 * @since 0.9
	 * @param rotate
	 *            if true, log file rotation is enabled.
	 */
	public void setRotate(boolean rotate) {
		this.rotate = rotate;
	}

	/**
	 * Sets a maximum size of a single log file. Exceeding this size causes
	 * rotation. This option is ignored if "rotate" is false.
	 * 
	 * @since 0.9
	 * @param maxFileSize
	 *            Max size of a single log file expressed in bytes, kilobytes,
	 *            megabytes or gigabytes by suffixing a numeric value with KB,
	 *            MB and respectively GB. For example, 5000000. Exceeding this
	 *            size causes rotation.
	 */
	public void setMaxFileSize(String maxFileSize) {
		this.maxFileSize = maxFileSize;
	}

	/**
	 * Sets a maximum number of log files to keep. Older files exceeding this
	 * number will be deleted.
	 * 
	 * @since 0.9
	 * @param maxFiles
	 *            maximum number of log files to keep.
	 */
	public void setMaxFiles(int maxFiles) {
		this.maxFiles = maxFiles;
	}

	/**
	 * @since 0.9
	 * @param maxTotalFileSize
	 *            maximum size of all log files combined.
	 */
	public void setMaxTotalFileSize(String maxTotalFileSize) {
		this.maxTotalFileSize = maxTotalFileSize;
	}

	@Override
	public Appender<ILoggingEvent> createAppender(LoggerContext context) {
		FileAppender<ILoggingEvent> appender = new FileAppender<>();
		appender.setFile(Objects.requireNonNull(file));
{'fraction_non_alphanumeric': 0.09229037703995498, 'fraction_numerical': 0.005627462014631401, 'mean_word_length': 3.6653543307086616, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2563148', 'n_tokens_mistral': 1147, 'n_tokens_neox': 1060, 'n_words': 327}