jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woonsan <...@git.apache.org>
Subject [GitHub] jmeter pull request #254: Feature/bz60589-1 PR for review (logkit to slf4j /...
Date Mon, 06 Feb 2017 22:11:35 GMT
Github user woonsan commented on a diff in the pull request:

    https://github.com/apache/jmeter/pull/254#discussion_r99698039
  
    --- Diff: src/core/org/apache/jmeter/NewDriver.java ---
    @@ -276,4 +276,106 @@ private static String exceptionsToString(List<Exception> exceptionsInInit)
{
             }
             return builder.toString();
         }
    +
    +    /*
    +     * Set logging related system properties.
    +     */
    +    private static void setLoggingProperties(String[] args) {
    +        String jmLogFile = getCommandLineArgument(args, (int) 'j', "jmeterlogfile");//
$NON-NLS-1$ $NON-NLS-2$
    +
    +        if (jmLogFile != null && !jmLogFile.isEmpty()) {
    +            jmLogFile = replaceDateFormatInFileName(jmLogFile);
    +            System.setProperty("jmeter.logfile", jmLogFile);// $NON-NLS-1$
    +        } else if (System.getProperty("jmeter.logfile") == null) {// $NON-NLS-1$
    +            System.setProperty("jmeter.logfile", "jmeter.log");// $NON-NLS-1$ $NON-NLS-2$
    +        }
    +
    +        String jmLogConf = getCommandLineArgument(args, (int) 'i', "jmeterlogconf");//
$NON-NLS-1$ $NON-NLS-2$
    +        File logConfFile = null;
    +
    +        if (jmLogConf != null && !jmLogConf.isEmpty()) {
    +            logConfFile = new File(jmLogConf);
    +        } else if (System.getProperty("log4j.configurationFile") == null) {// $NON-NLS-1$
    +            logConfFile = new File("log4j2.xml");// $NON-NLS-1$
    +            if (!logConfFile.isFile()) {
    +                logConfFile = new File(JMETER_INSTALLATION_DIRECTORY, "bin" + File.separator
+ "log4j2.xml");// $NON-NLS-1$ $NON-NLS-2$
    +            }
    +        }
    +
    +        if (logConfFile != null) {
    +            System.setProperty("log4j.configurationFile", logConfFile.toURI().toString());//
$NON-NLS-1$
    +        }
    +    }
    +
    +    /*
    +     * Find command line argument option value by the id and name.
    +     */
    +    private static String getCommandLineArgument(String [] args, int id, String name)
{
    +        final String shortArgName = "-" + ((char) id);// $NON-NLS-1$
    +        final String longArgName = "--" + name;// $NON-NLS-1$
    +
    +        String value = null;
    +
    +        for (int i = 0; i < args.length; i++) {
    +            if (shortArgName.equals(args[i]) && i < args.length - 1) {
    +                if (!args[i + 1].startsWith("-")) {// $NON-NLS-1$
    +                    value = args[i + 1];
    +                }
    +                break;
    +            } else if (!shortArgName.equals(args[i]) && args[i].startsWith(shortArgName))
{
    +                value = args[i].substring(shortArgName.length());
    +                break;
    +            } else if (longArgName.equals(args[i])) {
    +                if (!args[i + 1].startsWith("-")) {// $NON-NLS-1$
    +                    value = args[i + 1];
    +                }
    +                break;
    +            }
    +        }
    +
    +        return value;
    +    }
    +
    +    /*
    +     * If the fileName contains at least one set of paired single-quotes, reformat using
DateFormat
    +     */
    +    private static String replaceDateFormatInFileName(String fileName) {
    --- End diff --
    
    @vlsi That's different from what we have supported now as explains in http://jmeter.apache.org/usermanual/get-started.html#options.
It has an example without single quote escapes, which makes failure.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message