mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
fixes for logger out of order init, and CmdParser pattern for single character params
This commit is contained in:
@@ -45,7 +45,7 @@ import io.nosqlbench.engine.core.lifecycle.ExecutionResult;
|
||||
import io.nosqlbench.engine.core.lifecycle.process.NBCLIErrorHandler;
|
||||
import io.nosqlbench.engine.core.lifecycle.activity.ActivityTypeLoader;
|
||||
import io.nosqlbench.engine.core.lifecycle.session.NBSession;
|
||||
import io.nosqlbench.engine.core.logging.LoggerConfig;
|
||||
import io.nosqlbench.engine.core.logging.NBLoggerConfig;
|
||||
import io.nosqlbench.engine.core.metadata.MarkdownFinder;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
import io.nosqlbench.nb.annotations.ServiceSelector;
|
||||
@@ -68,13 +68,13 @@ import java.util.stream.Collectors;
|
||||
public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
|
||||
private static Logger logger;
|
||||
private static final LoggerConfig loggerConfig;
|
||||
private static final NBLoggerConfig loggerConfig;
|
||||
private static final int EXIT_OK = 0;
|
||||
private static final int EXIT_WARNING = 1;
|
||||
private static final int EXIT_ERROR = 2;
|
||||
|
||||
static {
|
||||
loggerConfig = new LoggerConfig();
|
||||
loggerConfig = new NBLoggerConfig();
|
||||
ConfigurationFactory.setConfigurationFactory(NBCLI.loggerConfig);
|
||||
}
|
||||
|
||||
@@ -169,9 +169,9 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
.setAnsiEnabled(globalOptions.isEnableAnsi())
|
||||
.setDedicatedVerificationLogger(globalOptions.isDedicatedVerificationLogger())
|
||||
.activate();
|
||||
ConfigurationFactory.setConfigurationFactory(NBCLI.loggerConfig);
|
||||
ConfigurationFactory.setConfigurationFactory(NBCLI.loggerConfig); // THIS should be the first time log4j2 is invoked!
|
||||
|
||||
NBCLI.logger = LogManager.getLogger("NBCLI");
|
||||
NBCLI.logger = LogManager.getLogger("NBCLI"); // TODO: Detect if the logger config was already initialized (error)
|
||||
NBCLI.loggerConfig.purgeOldFiles(LogManager.getLogger("SCENARIO"));
|
||||
if (NBCLI.logger.isInfoEnabled())
|
||||
NBCLI.logger.info(() -> "Configured scenario log at " + NBCLI.loggerConfig.getLogfileLocation());
|
||||
@@ -185,7 +185,7 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
}
|
||||
|
||||
NBCLI.logger.info(() -> "Running NoSQLBench Version " + new VersionInfo().getVersion());
|
||||
NBCLI.logger.info(() -> "command-line: " + Arrays.stream(args).collect(Collectors.joining(" ")));
|
||||
NBCLI.logger.info(() -> "command-line: " + String.join(" ", args));
|
||||
NBCLI.logger.info(() -> "client-hardware: " + SystemId.getHostSummary());
|
||||
|
||||
|
||||
|
||||
@@ -670,16 +670,24 @@ public class NBCLIOptions {
|
||||
|
||||
You can discover available ways to invoke PROG by using the various --list-* commands:
|
||||
[ --list-commands, --list-scripts, --list-workloads (and --list-scenarios), --list-apps ]
|
||||
"""
|
||||
.replaceAll("ARG", cmdParam)
|
||||
.replaceAll("PROG", "nb5")
|
||||
.replaceAll("INCLUDES", String.join(",", wantsIncludes()))
|
||||
;
|
||||
|
||||
final String debugMessage = """
|
||||
|
||||
After parsing all global options out of the command line, the remaining commands were found,
|
||||
and mapped to valid options as describe above. This command stream was:
|
||||
COMMANDSTREAM
|
||||
"""
|
||||
.replaceAll("ARG", cmdParam)
|
||||
.replaceAll("PROG", "nb5")
|
||||
.replaceAll("INCLUDES", String.join(",", wantsIncludes()))
|
||||
.replaceAll("COMMANDSTREAM",
|
||||
String.join(" ",arglist));
|
||||
if (consoleLevel.isGreaterOrEqualTo(NBLogLevel.INFO)) {
|
||||
System.out.println(debugMessage);
|
||||
}
|
||||
|
||||
throw new BasicError(helpmsg);
|
||||
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.regex.Pattern;
|
||||
* TODO: provide before and after atfile processing logs for diagnostics
|
||||
*/
|
||||
public class NBAtFile {
|
||||
private final static Logger logger = LogManager.getLogger(NBAtFile.class);
|
||||
// private final static Logger logger = LogManager.getLogger(NBAtFile.class);
|
||||
|
||||
/**
|
||||
* This will take a command line in raw form, which may include some arguments
|
||||
@@ -51,7 +51,7 @@ public class NBAtFile {
|
||||
* @throws RuntimeException for any errors finding, traversing, parsing, or rendering values
|
||||
*/
|
||||
public static LinkedList<String> includeAt(LinkedList<String> processInPlace) {
|
||||
logger.trace("argv stream before processing: " + String.join("|",processInPlace));
|
||||
// logger.trace("argv stream before processing: " + String.join("|",processInPlace));
|
||||
ListIterator<String> iter = processInPlace.listIterator();
|
||||
while (iter.hasNext()) {
|
||||
String spec = iter.next();
|
||||
@@ -64,7 +64,7 @@ public class NBAtFile {
|
||||
}
|
||||
}
|
||||
}
|
||||
logger.trace("argv stream after atfile processing: "+ String.join("|",processInPlace));
|
||||
// logger.trace("argv stream after atfile processing: "+ String.join("|",processInPlace));
|
||||
|
||||
return processInPlace;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class NBAtFile {
|
||||
NBPathsAPI.GetExtensions wantsExtension = NBIO.local().pathname(filepathSpec);
|
||||
String extension = (!filepathSpec.toLowerCase().endsWith(".yaml")) ? "yaml" : "";
|
||||
if (!extension.isEmpty()) {
|
||||
logger.debug("adding extension 'yaml' to at-file path '" + filepathSpec + "'");
|
||||
// logger.debug("adding extension 'yaml' to at-file path '" + filepathSpec + "'");
|
||||
wantsExtension.extensionSet("yaml");
|
||||
}
|
||||
Content<?> argsContent = wantsExtension.one();
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
/**
|
||||
* <P>Take zero or more strings containing combined argv and return
|
||||
* a single {@link Cmd} list containing zero or more commands.</P>
|
||||
@@ -46,7 +45,7 @@ public class CmdParser {
|
||||
private record parameter(String name, String op, String value) {}
|
||||
private record command(String name){}
|
||||
private final static Pattern combinedPattern =
|
||||
Pattern.compile("(?<varname>[a-zA-Z_][a-zA-Z0-9_.-]+)(?<operator>=+)(?<value>.+)|(?<command>[a-zA-Z_][a-zA-Z0-9_.]+)",Pattern.DOTALL);
|
||||
Pattern.compile("(?<varname>[a-zA-Z_][a-zA-Z0-9_.-]*)(?<operator>=+)(?<value>.+)|(?<command>[a-zA-Z_][a-zA-Z0-9_.]*)",Pattern.DOTALL);
|
||||
private final static Pattern commandName =Pattern.compile("^$");
|
||||
public static LinkedList<Cmd> parseArgvCommands(LinkedList<String> args) {
|
||||
LinkedList<Record> cmdstructs = new LinkedList<>();
|
||||
|
||||
@@ -52,7 +52,7 @@ import java.util.stream.Collectors;
|
||||
*
|
||||
* @see <a href="https://logging.apache.org/log4j/2.x/manual/layouts.html#Pattern_Layout">Pattern Layout</a>
|
||||
*/
|
||||
public class LoggerConfig extends ConfigurationFactory {
|
||||
public class NBLoggerConfig extends ConfigurationFactory {
|
||||
|
||||
public static Map<String, String> STANDARD_FORMATS = Map.of(
|
||||
"TERSE", "%8r %-5level [%t] %-12logger{0} %msg%n%throwable",
|
||||
@@ -92,25 +92,25 @@ public class LoggerConfig extends ConfigurationFactory {
|
||||
private boolean isDedicatedVerificationLoggerEnabled = false;
|
||||
|
||||
|
||||
public LoggerConfig() {
|
||||
public NBLoggerConfig() {
|
||||
}
|
||||
|
||||
public LoggerConfig setAnsiEnabled(boolean ansiEnabled) {
|
||||
public NBLoggerConfig setAnsiEnabled(boolean ansiEnabled) {
|
||||
this.ansiEnabled = ansiEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoggerConfig setConsoleLevel(NBLogLevel level) {
|
||||
public NBLoggerConfig setConsoleLevel(NBLogLevel level) {
|
||||
this.consoleLevel = level;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoggerConfig setLogfileLevel(NBLogLevel level) {
|
||||
public NBLoggerConfig setLogfileLevel(NBLogLevel level) {
|
||||
this.fileLevel = level;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoggerConfig setDedicatedVerificationLogger(boolean enabled) {
|
||||
public NBLoggerConfig setDedicatedVerificationLogger(boolean enabled) {
|
||||
this.isDedicatedVerificationLoggerEnabled = enabled;
|
||||
return this;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class LoggerConfig extends ConfigurationFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public LoggerConfig setMaxLogs(int maxLogfiles) {
|
||||
public NBLoggerConfig setMaxLogs(int maxLogfiles) {
|
||||
this.maxLogfiles = maxLogfiles;
|
||||
return this;
|
||||
}
|
||||
@@ -298,7 +298,7 @@ public class LoggerConfig extends ConfigurationFactory {
|
||||
ConfigurationFactory.setConfigurationFactory(this);
|
||||
}
|
||||
|
||||
public LoggerConfig setConsolePattern(String consoleLoggingPattern) {
|
||||
public NBLoggerConfig setConsolePattern(String consoleLoggingPattern) {
|
||||
|
||||
consoleLoggingPattern = (ansiEnabled && STANDARD_FORMATS.containsKey(consoleLoggingPattern + "-ANSI"))
|
||||
? consoleLoggingPattern + "-ANSI" : consoleLoggingPattern;
|
||||
@@ -307,7 +307,7 @@ public class LoggerConfig extends ConfigurationFactory {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoggerConfig setLogfilePattern(String logfileLoggingPattern) {
|
||||
public NBLoggerConfig setLogfilePattern(String logfileLoggingPattern) {
|
||||
logfileLoggingPattern = (logfileLoggingPattern.endsWith("-ANSI") && STANDARD_FORMATS.containsKey(logfileLoggingPattern))
|
||||
? logfileLoggingPattern.substring(logfileLoggingPattern.length() - 5) : logfileLoggingPattern;
|
||||
|
||||
@@ -315,7 +315,7 @@ public class LoggerConfig extends ConfigurationFactory {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoggerConfig setLoggerLevelOverrides(Map<String, String> logLevelOverrides) {
|
||||
public NBLoggerConfig setLoggerLevelOverrides(Map<String, String> logLevelOverrides) {
|
||||
this.logLevelOverrides = logLevelOverrides;
|
||||
return this;
|
||||
}
|
||||
@@ -324,12 +324,12 @@ public class LoggerConfig extends ConfigurationFactory {
|
||||
return logLevelOverrides;
|
||||
}
|
||||
|
||||
public LoggerConfig setSessionName(String sessionName) {
|
||||
public NBLoggerConfig setSessionName(String sessionName) {
|
||||
this.sessionName = sessionName;
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoggerConfig purgeOldFiles(Logger logger) {
|
||||
public NBLoggerConfig purgeOldFiles(Logger logger) {
|
||||
if (maxLogfiles == 0) {
|
||||
logger.debug("Not purging old files, since maxLogFiles is 0.");
|
||||
return this;
|
||||
@@ -384,7 +384,7 @@ public class LoggerConfig extends ConfigurationFactory {
|
||||
return logfileLocation;
|
||||
}
|
||||
|
||||
public LoggerConfig setLogsDirectory(Path logsDirectory) {
|
||||
public NBLoggerConfig setLogsDirectory(Path logsDirectory) {
|
||||
this.loggerDir = logsDirectory;
|
||||
return this;
|
||||
}
|
||||
Reference in New Issue
Block a user