diff --git a/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java b/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java index 11936128..b9931cbd 100755 --- a/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java +++ b/Mustang-CLI/src/main/java/org/mustangproject/commandline/Main.java @@ -43,65 +43,65 @@ import org.slf4j.LoggerFactory; import javax.xml.transform.TransformerException; public class Main { - private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Validator.class.getCanonicalName()); // log output - + private static org.slf4j.Logger LOGGER; // log output private static void printUsage() { System.err.println(getUsage()); } private static String getUsage() { - return "Usage: --action metrics|combine|extract|a3only|ubl|validate|validateExpectInvalid|validateExpectValid|visualize [-d,--directory] [-l,--listfromstdin] [-i,--ignore fileextension, PDF/A errors] | [-h,--help] \r\n" - + " --action license display open source license and notice\n" - + " --action metrics\n" - + " -d, --directory count ZUGFeRD files in directory to be scanned\n" - + " If it is a directory, it will recurse.\n" - + " -l, --listfromstdin count ZUGFeRD files from a list of linefeed separated files on runtime.\n" - + " It will start once a blank line has been entered.\n" + "\n" - + " Additional parameter for both count operations\n" - + " [-i, --ignorefileextension] Check for all files (*.*) instead of PDF files only (*.pdf) in metrics, ignore PDF/A input file errors in combine\n" - + " --action extract extract Factur-X PDF to XML file\n" - + " Additional parameters (optional - user will be prompted if not defined)\n" - + " [--source ]: set input PDF file\n" - + " [--out ]: set output XML file\n" - + " --action a3only upgrade from PDF/A1 to A3 only (no ZUGFeRD data attached)\n" - + " Additional parameters (optional - user will be prompted if not defined)\n" - + " [--source ]: set input PDF file\n" - + " [--out ]: set output PDF file\n" - + " --action combine combine XML and PDF file to Factur-X PDF file\n" - + " Additional parameters (optional - user will be prompted if not defined)\n" - + " [--source ]: set input PDF file\n" - + " [--source-xml ]: set input XML file\n" - + " [--out ]: set output PDF file\n" - + " [--format ]: set Factur-X, ZUGFeRD, Order-X or Cross Industry Despatch Advice\n" - + " [--version <1|2>]: set ZUGFeRD version\n" - + " [--profile <...>]: set ZUGFeRD profile\n" - + " For ZUGFeRD v1 or Order-X: ASIC, OMFORT or EXENDED\n" - + " For ZUGFeRD v2: INIMUM, BASIC L, ASIC, IUS, N16931, Rechnung, EXENDED\n" - + " [--attachments ]: list of file attachments (passing a single empty file name prevents prompting)\n" - + " --action ubl convert UN/CEFACT 2016b CII XML to UBL XML\n" - + " [--source ]: set input XML file\n" - + " [--out ]: set output XML file\n" - + " --action upgrade upgrade ZUGFeRD XML to ZUGFeRD 2 XML\n" - + " Additional parameters (optional - user will be prompted if not defined)\n" - + " [--source ]: set input XML ZUGFeRD 1 file\n" - + " [--out ]: set output XML ZUGFeRD 2 file\n" - + " --action validate validate XML or PDF file \n" - + " [--no-notices]: refrain from reporting notices\n" - + " [--logAppend ]: text to be added to log line\n" - + " Additional parameters (optional - user will be prompted if not defined)\n" - + " [--source ]: input PDF or XML file\n" - + " --action validateExpectInvalid validate directory expecting negative results \n" - + " [--no-notices]: refrain from reporting notices\n" - + " Additional parameters (optional - user will be prompted if not defined)\n" - + " -d, --directory to check recursively\n" - + " --action validateExpectValid validate directory expecting positive results \n" - + " [--no-notices]: refrain from reporting notices\n" - + " Additional parameters (optional - user will be prompted if not defined)\n" - + " -d, --directory to check recursively \n" - + " --action visualize convert XML to HTML \n" - + " [--language ]: set output lang (en, fr or de)\n" - + " [--source ]: set input XML file\n" - + " [--out ]: set output HTML file\n" + return "Usage: --action metrics|combine|extract|a3only|ubl|validate|validateExpectInvalid|validateExpectValid|visualize [-d,--directory] [-l,--listfromstdin] [-i,--ignore fileextension, PDF/A errors] [--disable-file-logging] | [-h,--help] \r\n" + + " --action license display open source license and notice\n" + + " --action metrics\n" + + " -d, --directory count ZUGFeRD files in directory to be scanned\n" + + " If it is a directory, it will recurse.\n" + + " -l, --listfromstdin count ZUGFeRD files from a list of linefeed separated files on runtime.\n" + + " It will start once a blank line has been entered.\n" + "\n" + + " Additional parameter for both count operations\n" + + " [-i, --ignorefileextension] Check for all files (*.*) instead of PDF files only (*.pdf) in metrics, ignore PDF/A input file errors in combine\n" + + " [--disable-file-logging] disable logging to file.\n" + + " --action extract extract Factur-X PDF to XML file\n" + + " Additional parameters (optional - user will be prompted if not defined)\n" + + " [--source ]: set input PDF file\n" + + " [--out ]: set output XML file\n" + + " --action a3only upgrade from PDF/A1 to A3 only (no ZUGFeRD data attached)\n" + + " Additional parameters (optional - user will be prompted if not defined)\n" + + " [--source ]: set input PDF file\n" + + " [--out ]: set output PDF file\n" + + " --action combine combine XML and PDF file to Factur-X PDF file\n" + + " Additional parameters (optional - user will be prompted if not defined)\n" + + " [--source ]: set input PDF file\n" + + " [--source-xml ]: set input XML file\n" + + " [--out ]: set output PDF file\n" + + " [--format ]: set Factur-X, ZUGFeRD, Order-X or Cross Industry Despatch Advice\n" + + " [--version <1|2>]: set ZUGFeRD version\n" + + " [--profile <...>]: set ZUGFeRD profile\n" + + " For ZUGFeRD v1 or Order-X: ASIC, OMFORT or EXENDED\n" + + " For ZUGFeRD v2: INIMUM, BASIC L, ASIC, IUS, N16931, Rechnung, EXENDED\n" + + " [--attachments ]: list of file attachments (passing a single empty file name prevents prompting)\n" + + " --action ubl convert UN/CEFACT 2016b CII XML to UBL XML\n" + + " [--source ]: set input XML file\n" + + " [--out ]: set output XML file\n" + + " --action upgrade upgrade ZUGFeRD XML to ZUGFeRD 2 XML\n" + + " Additional parameters (optional - user will be prompted if not defined)\n" + + " [--source ]: set input XML ZUGFeRD 1 file\n" + + " [--out ]: set output XML ZUGFeRD 2 file\n" + + " --action validate validate XML or PDF file \n" + + " [--no-notices]: refrain from reporting notices\n" + + " [--logAppend ]: text to be added to log line\n" + + " Additional parameters (optional - user will be prompted if not defined)\n" + + " [--source ]: input PDF or XML file\n" + + " --action validateExpectInvalid validate directory expecting negative results \n" + + " [--no-notices]: refrain from reporting notices\n" + + " Additional parameters (optional - user will be prompted if not defined)\n" + + " -d, --directory to check recursively\n" + + " --action validateExpectValid validate directory expecting positive results \n" + + " [--no-notices]: refrain from reporting notices\n" + + " Additional parameters (optional - user will be prompted if not defined)\n" + + " -d, --directory to check recursively \n" + + " --action visualize convert XML to HTML \n" + + " [--language ]: set output lang (en, fr or de)\n" + + " [--source ]: set input XML file\n" + + " [--out ]: set output HTML file\n" + " --action pdf convert XML to PDF \n" + " [--source ]: set input XML file\n" + " [--out ]: set output PDF file\n" @@ -351,17 +351,19 @@ public class Main { attachmentOpt.setValueSeparator(','); attachmentOpt.setArgs(Option.UNLIMITED_VALUES); options.addOption(attachmentOpt); - options.addOption(new Option("", "source", true, "which source file to use")); - options.addOption(new Option("", "source-xml", true, "which source file to use")); - options.addOption(new Option("", "language", true, "output language (en, de or fr)")); - options.addOption(new Option("", "out", true, "which output file to write to")); - options.addOption(new Option("", "no-notices", false, "suppress non-fatal errors")); - options.addOption(new Option("", "logAppend", true, "freeform text to be appended to log messages")); - options.addOption(new Option("d", "directory", true, "which directory to operate on")); - options.addOption(new Option("i", "ignorefileextension", false, "ignore non-matching file extensions")); - options.addOption(new Option("l", "listfromstdin", false, "take list of files from commandline")); - boolean optionsRecognized = false; + options.addOption(new Option("", "source",true, "which source file to use")); + options.addOption(new Option("", "source-xml",true, "which source file to use")); + options.addOption(new Option("", "language",true, "output language (en, de or fr)")); + options.addOption(new Option("", "out",true, "which output file to write to")); + options.addOption(new Option("", "no-notices",false, "suppress non-fatal errors")); + options.addOption(new Option("", "logAppend",true, "freeform text to be appended to log messages")); + options.addOption(new Option("", "disable-file-logging", false, "suppress logging to file")); + options.addOption(new Option("d", "directory",true, "which directory to operate on")); + options.addOption(new Option("i", "ignorefileextension",false, "ignore non-matching file extensions")); + options.addOption(new Option("l", "listfromstdin",false, "take list of files from commandline")); + boolean optionsRecognized=false; String action = ""; + Boolean disableFileLogging = false; try { cmd = parser.parse(options, args); @@ -370,7 +372,8 @@ public class Main { String directoryName = cmd.getOptionValue("directory"); Boolean filesFromStdIn = cmd.hasOption("listfromstdin");//((Number)cmdLine.getParsedOptionValue("integer-option")).intValue(); Boolean ignoreFileExt = cmd.hasOption("ignorefileextension"); - Boolean helpRequested = cmd.hasOption("help") || ((action != null) && (action.equals("help"))); + Boolean helpRequested = cmd.hasOption("help") || ((action!=null)&&(action.equals("help"))); + disableFileLogging = cmd.hasOption("disable-file-logging"); String sourceName = cmd.getOptionValue("source"); String sourceXMLName = cmd.getOptionValue("source-xml"); @@ -385,7 +388,17 @@ public class Main { String[] attachmentFilenames = cmd.hasOption("attachments") ? cmd.getOptionValues("attachments") : null; - ArrayList attachments = new ArrayList<>(); + + + ArrayList attachments=new ArrayList <>(); + /* + setting system property to disable FILE appender and + suppress creation of files and folders. + */ + System.setProperty("FILE_APPENDER_ENABLED", ((Boolean)(disableFileLogging==false)).toString()); + + LOGGER = LoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME); + if (helpRequested) { printHelp(); optionsRecognized = true; diff --git a/Mustang-CLI/src/main/resources/logback.xml b/Mustang-CLI/src/main/resources/logback.xml index 8473cbd9..d8c56d7e 100644 --- a/Mustang-CLI/src/main/resources/logback.xml +++ b/Mustang-CLI/src/main/resources/logback.xml @@ -1,37 +1,38 @@ - - - - System.err - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - + - - - - - - log/ZUV-%d{yyyy-MM}.log - - - 60 - - + + System.err - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - + - - - - - - + + + + + + + log/ZUV-%d{yyyy-MM}.log + + + 60 + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + - - + + + + + + + + + +