All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.credibledoc.combiner.CombinerCommandLineMain Maven / Gradle / Ivy

Go to download

Simple command-line tool for merging log files with different format of lines timestamps to a single file or readable source with lines sorted by timestamps. See the https://github.com/credibledoc/credible-doc/tree/master/log-combiner-parent/log-combiner page.

There is a newer version: 1.0.51
Show newest version
package com.credibledoc.combiner;

import com.credibledoc.combiner.context.CombinerContext;
import com.credibledoc.combiner.exception.CombinerRuntimeException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

/**
 * This class contains a main method for launching of the {@link #LOG_COMBINER_MODULE_NAME} tool.
 */
public class CombinerCommandLineMain {
    private static final Logger logger = LoggerFactory.getLogger(CombinerCommandLineMain.class);
    static final String LOG_COMBINER_MODULE_NAME = "log-combiner-parent/log-combiner";
    private static final String LOG_COMBINER_REPOSITORY_NAME = "credible-doc";
    private static final String LINE_SEPARATOR = System.lineSeparator();

    public static void main(String[] arguments) {
        // arguments validation
        if (arguments.length < 1) {
            // print command-line options
            logger.info("Usage of the {} tool.{}" +
                "java -jar {}.jar  [configAbsolutePath]{}" +
                "More examples see on https://github.com/credibledoc/{}/tree/master/{}",
                LOG_COMBINER_MODULE_NAME,
                LINE_SEPARATOR,
                LOG_COMBINER_MODULE_NAME,
                LINE_SEPARATOR,
                LOG_COMBINER_REPOSITORY_NAME,
                LOG_COMBINER_MODULE_NAME);
            System.exit(0);
        }
        String folderAbsolutePath = arguments[0];
        logger.info("Source folderAbsolutePath: '{}'", folderAbsolutePath);

        File folder = new File(folderAbsolutePath);
        if (!folder.exists()) {
            throw new CombinerRuntimeException("Folder not found: '" + folder.getAbsolutePath() + "'.");
        }

        String configAbsolutePath = null;
        if (arguments.length > 1) {
            configAbsolutePath = arguments[1];
        }
        logger.info("Configuration configAbsolutePath: '{}'", configAbsolutePath);

        // Contains instances of Tactics, NodeFiles and NodeLogs
        CombinerContext combinerContext = new CombinerContext().init();
        
        CombinerService.getInstance().combine(folder, configAbsolutePath, combinerContext);
        logger.info("Application {} finished.", LOG_COMBINER_MODULE_NAME);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy