diff --git a/distribution/tools/cli-launcher/src/main/java/org/elasticsearch/launcher/CliToolLauncher.java b/distribution/tools/cli-launcher/src/main/java/org/elasticsearch/launcher/CliToolLauncher.java index 5952def15ad8c..6f001258e3fb4 100644 --- a/distribution/tools/cli-launcher/src/main/java/org/elasticsearch/launcher/CliToolLauncher.java +++ b/distribution/tools/cli-launcher/src/main/java/org/elasticsearch/launcher/CliToolLauncher.java @@ -8,9 +8,12 @@ package org.elasticsearch.launcher; +import org.apache.logging.log4j.Level; import org.elasticsearch.cli.CliToolProvider; import org.elasticsearch.cli.Command; import org.elasticsearch.cli.Terminal; +import org.elasticsearch.common.logging.LogConfigurator; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.SuppressForbidden; import java.util.Map; @@ -43,6 +46,10 @@ class CliToolLauncher { */ public static void main(String[] args) throws Exception { Map sysprops = getSystemProperties(); + + // configure logging as early as possible + configureLoggingWithoutConfig(sysprops); + String toolname = getToolName(sysprops); String libs = sysprops.getOrDefault("cli.libs", ""); @@ -76,4 +83,15 @@ private static Map getSystemProperties() { private static void exit(int status) { System.exit(status); } + + /** + * Configures logging without Elasticsearch configuration files based on the system property "es.logger.level" only. As such, any + * logging will be written to the console. + */ + private static void configureLoggingWithoutConfig(Map sysprops) { + // initialize default for es.logger.level because we will not read the log4j2.properties + final String loggerLevel = sysprops.getOrDefault("es.logger.level", Level.INFO.name()); + final Settings settings = Settings.builder().put("logger.level", loggerLevel).build(); + LogConfigurator.configureWithoutConfig(settings); + } } diff --git a/distribution/tools/geoip-cli/src/main/java/org/elasticsearch/geoip/GeoIpCli.java b/distribution/tools/geoip-cli/src/main/java/org/elasticsearch/geoip/GeoIpCli.java index 6c6a2b0b03cad..56aa9ad20b2a5 100644 --- a/distribution/tools/geoip-cli/src/main/java/org/elasticsearch/geoip/GeoIpCli.java +++ b/distribution/tools/geoip-cli/src/main/java/org/elasticsearch/geoip/GeoIpCli.java @@ -47,7 +47,7 @@ public class GeoIpCli extends Command { private final OptionSpec targetDirectory; public GeoIpCli() { - super("A CLI tool to prepare local GeoIp database service", () -> {}); + super("A CLI tool to prepare local GeoIp database service"); sourceDirectory = parser.acceptsAll(Arrays.asList("s", "source"), "Source directory").withRequiredArg().required(); targetDirectory = parser.acceptsAll(Arrays.asList("t", "target"), "Target directory").withRequiredArg(); diff --git a/distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/KeyStoreCli.java b/distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/KeyStoreCli.java index 81acf200d7848..99778a4750e07 100644 --- a/distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/KeyStoreCli.java +++ b/distribution/tools/keystore-cli/src/main/java/org/elasticsearch/cli/keystore/KeyStoreCli.java @@ -8,12 +8,12 @@ package org.elasticsearch.cli.keystore; -import org.elasticsearch.common.cli.LoggingAwareMultiCommand; +import org.elasticsearch.cli.MultiCommand; /** * A cli tool for managing secrets in the elasticsearch keystore. */ -class KeyStoreCli extends LoggingAwareMultiCommand { +class KeyStoreCli extends MultiCommand { KeyStoreCli() { super("A tool for managing settings stored in the elasticsearch keystore"); diff --git a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/PluginCli.java b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/PluginCli.java index 77bc80b851359..2d26080750225 100644 --- a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/PluginCli.java +++ b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/cli/PluginCli.java @@ -9,7 +9,7 @@ package org.elasticsearch.plugins.cli; import org.elasticsearch.cli.Command; -import org.elasticsearch.common.cli.LoggingAwareMultiCommand; +import org.elasticsearch.cli.MultiCommand; import org.elasticsearch.core.internal.io.IOUtils; import java.io.IOException; @@ -19,7 +19,7 @@ /** * A cli tool for adding, removing and listing plugins for elasticsearch. */ -class PluginCli extends LoggingAwareMultiCommand { +class PluginCli extends MultiCommand { private final Collection commands; diff --git a/libs/cli/src/main/java/org/elasticsearch/cli/Command.java b/libs/cli/src/main/java/org/elasticsearch/cli/Command.java index bfa47f5f93cf7..d4702deb57426 100644 --- a/libs/cli/src/main/java/org/elasticsearch/cli/Command.java +++ b/libs/cli/src/main/java/org/elasticsearch/cli/Command.java @@ -33,8 +33,6 @@ public abstract class Command implements Closeable { /** A description of the command, used in the help output. */ protected final String description; - private final Runnable beforeMain; - // these are the system properties and env vars from the environment, // but they can be overriden by tests. Really though Command should be stateless, // so the signature of main should take them in, which can happen once the entrypoint @@ -52,13 +50,11 @@ public abstract class Command implements Closeable { /** * Construct the command with the specified command description and runnable to execute before main is invoked. + * @param description the command description * - * @param description the command description - * @param beforeMain the before-main runnable */ - public Command(final String description, final Runnable beforeMain) { + public Command(final String description) { this.description = description; - this.beforeMain = beforeMain; this.sysprops = captureSystemProperties(); this.envVars = captureEnvironmentVariables(); } @@ -86,8 +82,6 @@ public final int main(String[] args, Terminal terminal) throws Exception { Runtime.getRuntime().addShutdownHook(shutdownHookThread); } - beforeMain.run(); - try { mainWithoutErrorHandling(args, terminal); } catch (OptionException e) { diff --git a/libs/cli/src/main/java/org/elasticsearch/cli/MultiCommand.java b/libs/cli/src/main/java/org/elasticsearch/cli/MultiCommand.java index acda0c70c592e..451392037132f 100644 --- a/libs/cli/src/main/java/org/elasticsearch/cli/MultiCommand.java +++ b/libs/cli/src/main/java/org/elasticsearch/cli/MultiCommand.java @@ -34,12 +34,11 @@ public class MultiCommand extends Command { /** * Construct the multi-command with the specified command description and runnable to execute before main is invoked. + * @param description the multi-command description * - * @param description the multi-command description - * @param beforeMain the before-main runnable */ - public MultiCommand(final String description, final Runnable beforeMain) { - super(description, beforeMain); + public MultiCommand(final String description) { + super(description); this.settingOption = parser.accepts("E", "Configure a setting").withRequiredArg().ofType(KeyValuePair.class); parser.posixlyCorrect(true); } diff --git a/qa/evil-tests/src/test/java/org/elasticsearch/cli/EvilCommandTests.java b/qa/evil-tests/src/test/java/org/elasticsearch/cli/EvilCommandTests.java index 7fb22afd76d23..db7ec4a438d26 100644 --- a/qa/evil-tests/src/test/java/org/elasticsearch/cli/EvilCommandTests.java +++ b/qa/evil-tests/src/test/java/org/elasticsearch/cli/EvilCommandTests.java @@ -24,7 +24,7 @@ public class EvilCommandTests extends ESTestCase { public void testCommandShutdownHook() throws Exception { final AtomicBoolean closed = new AtomicBoolean(); final boolean shouldThrow = randomBoolean(); - final Command command = new Command("test-command-shutdown-hook", () -> {}) { + final Command command = new Command("test-command-shutdown-hook") { @Override protected void execute(Terminal terminal, OptionSet options) throws Exception { diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java b/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java index 4efc392fa483e..ff55d03f8b18b 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java @@ -42,7 +42,7 @@ class Elasticsearch extends EnvironmentAwareCommand { // visible for testing Elasticsearch() { - super("Starts Elasticsearch", () -> {}); // we configure logging later so we override the base class from configuring logging + super("Starts Elasticsearch"); // we configure logging later so we override the base class from configuring logging versionOption = parser.acceptsAll(Arrays.asList("V", "version"), "Prints Elasticsearch version information and exits"); daemonizeOption = parser.acceptsAll(Arrays.asList("d", "daemonize"), "Starts Elasticsearch in the background") .availableUnless(versionOption); diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/NodeToolCli.java b/server/src/main/java/org/elasticsearch/cluster/coordination/NodeToolCli.java index 31aa49018aad3..58f37ec220669 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/NodeToolCli.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/NodeToolCli.java @@ -8,22 +8,13 @@ package org.elasticsearch.cluster.coordination; import org.elasticsearch.cli.MultiCommand; -import org.elasticsearch.common.cli.CommandLoggingConfigurator; import org.elasticsearch.env.NodeRepurposeCommand; import org.elasticsearch.env.OverrideNodeVersionCommand; -// NodeToolCli does not extend LoggingAwareCommand, because LoggingAwareCommand performs logging initialization -// after LoggingAwareCommand instance is constructed. -// It's too late for us, because before UnsafeBootstrapMasterCommand is added to the list of subcommands -// log4j2 initialization will happen, because it has static reference to Logger class. -// Even if we avoid making a static reference to Logger class, there is no nice way to avoid declaring -// UNSAFE_BOOTSTRAP, which depends on ClusterService, which in turn has static Logger. -// TODO execute CommandLoggingConfigurator.configureLoggingWithoutConfig() in the constructor of commands, not in beforeMain class NodeToolCli extends MultiCommand { NodeToolCli() { - super("A CLI tool to do unsafe cluster and index manipulations on current node", () -> {}); - CommandLoggingConfigurator.configureLoggingWithoutConfig(); + super("A CLI tool to do unsafe cluster and index manipulations on current node"); subcommands.put("repurpose", new NodeRepurposeCommand()); subcommands.put("unsafe-bootstrap", new UnsafeBootstrapMasterCommand()); subcommands.put("detach-cluster", new DetachClusterCommand()); diff --git a/server/src/main/java/org/elasticsearch/common/cli/CommandLoggingConfigurator.java b/server/src/main/java/org/elasticsearch/common/cli/CommandLoggingConfigurator.java deleted file mode 100644 index 41a077cd769f5..0000000000000 --- a/server/src/main/java/org/elasticsearch/common/cli/CommandLoggingConfigurator.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.common.cli; - -import org.apache.logging.log4j.Level; -import org.elasticsearch.common.logging.LogConfigurator; -import org.elasticsearch.common.settings.Settings; - -/** - * Holder class for method to configure logging without Elasticsearch configuration files for use in CLI tools that will not read such - * files. - */ -public final class CommandLoggingConfigurator { - - /** - * Configures logging without Elasticsearch configuration files based on the system property "es.logger.level" only. As such, any - * logging will be written to the console. - */ - public static void configureLoggingWithoutConfig() { - // initialize default for es.logger.level because we will not read the log4j2.properties - final String loggerLevel = System.getProperty("es.logger.level", Level.INFO.name()); - final Settings settings = Settings.builder().put("logger.level", loggerLevel).build(); - LogConfigurator.configureWithoutConfig(settings); - } - -} diff --git a/server/src/main/java/org/elasticsearch/common/cli/EnvironmentAwareCommand.java b/server/src/main/java/org/elasticsearch/common/cli/EnvironmentAwareCommand.java index 4ef7650ffbb08..0a70189e7cb7a 100644 --- a/server/src/main/java/org/elasticsearch/common/cli/EnvironmentAwareCommand.java +++ b/server/src/main/java/org/elasticsearch/common/cli/EnvironmentAwareCommand.java @@ -39,18 +39,7 @@ public abstract class EnvironmentAwareCommand extends Command { * @param description the command description */ public EnvironmentAwareCommand(final String description) { - this(description, CommandLoggingConfigurator::configureLoggingWithoutConfig); - } - - /** - * Construct the command with the specified command description and runnable to execute before main is invoked. Commands constructed - * with this constructor must take ownership of configuring logging. - * - * @param description the command description - * @param beforeMain the before-main runnable - */ - public EnvironmentAwareCommand(final String description, final Runnable beforeMain) { - super(description, beforeMain); + super(description); this.settingOption = parser.accepts("E", "Configure a setting").withRequiredArg().ofType(KeyValuePair.class); } diff --git a/server/src/main/java/org/elasticsearch/common/cli/LoggingAwareCommand.java b/server/src/main/java/org/elasticsearch/common/cli/LoggingAwareCommand.java deleted file mode 100644 index 9682a5680eb05..0000000000000 --- a/server/src/main/java/org/elasticsearch/common/cli/LoggingAwareCommand.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.common.cli; - -import org.elasticsearch.cli.Command; - -/** - * A command that is aware of logging. This class should be preferred over the base {@link Command} class for any CLI tools that depend on - * core Elasticsearch as they could directly or indirectly touch classes that touch logging and as such logging needs to be configured. - */ -public abstract class LoggingAwareCommand extends Command { - - /** - * Construct the command with the specified command description. This command will have logging configured without reading Elasticsearch - * configuration files. - * - * @param description the command description - */ - public LoggingAwareCommand(final String description) { - super(description, CommandLoggingConfigurator::configureLoggingWithoutConfig); - } - -} diff --git a/server/src/main/java/org/elasticsearch/common/cli/LoggingAwareMultiCommand.java b/server/src/main/java/org/elasticsearch/common/cli/LoggingAwareMultiCommand.java deleted file mode 100644 index d3996d815d1da..0000000000000 --- a/server/src/main/java/org/elasticsearch/common/cli/LoggingAwareMultiCommand.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.common.cli; - -import org.elasticsearch.cli.MultiCommand; - -/** - * A multi-command that is aware of logging. This class should be preferred over the base {@link MultiCommand} class for any CLI tools that - * depend on core Elasticsearch as they could directly or indirectly touch classes that touch logging and as such logging needs to be - * configured. - */ -public abstract class LoggingAwareMultiCommand extends MultiCommand { - - /** - * Construct the command with the specified command description. This command will have logging configured without reading Elasticsearch - * configuration files. - * - * @param description the command description - */ - public LoggingAwareMultiCommand(final String description) { - super(description, CommandLoggingConfigurator::configureLoggingWithoutConfig); - } - -} diff --git a/server/src/main/java/org/elasticsearch/index/shard/ShardToolCli.java b/server/src/main/java/org/elasticsearch/index/shard/ShardToolCli.java index 488077d11c312..215dccb52918f 100644 --- a/server/src/main/java/org/elasticsearch/index/shard/ShardToolCli.java +++ b/server/src/main/java/org/elasticsearch/index/shard/ShardToolCli.java @@ -7,12 +7,12 @@ */ package org.elasticsearch.index.shard; -import org.elasticsearch.common.cli.LoggingAwareMultiCommand; +import org.elasticsearch.cli.MultiCommand; /** * Class encapsulating and dispatching commands from the {@code elasticsearch-shard} command line tool */ -class ShardToolCli extends LoggingAwareMultiCommand { +class ShardToolCli extends MultiCommand { ShardToolCli() { super("A CLI tool to remove corrupted parts of unrecoverable shards"); diff --git a/server/src/test/java/org/elasticsearch/cli/CommandTests.java b/server/src/test/java/org/elasticsearch/cli/CommandTests.java index c295d9f9a825d..b83f3cc58d369 100644 --- a/server/src/test/java/org/elasticsearch/cli/CommandTests.java +++ b/server/src/test/java/org/elasticsearch/cli/CommandTests.java @@ -34,7 +34,7 @@ static class DummyCommand extends Command { Exception exception = null; DummyCommand() { - super("Does nothing", () -> {}); + super("Does nothing"); } @Override diff --git a/server/src/test/java/org/elasticsearch/cli/MultiCommandTests.java b/server/src/test/java/org/elasticsearch/cli/MultiCommandTests.java index 578f2aabee5c8..e2a229be6d12e 100644 --- a/server/src/test/java/org/elasticsearch/cli/MultiCommandTests.java +++ b/server/src/test/java/org/elasticsearch/cli/MultiCommandTests.java @@ -30,7 +30,7 @@ static class DummyMultiCommand extends MultiCommand { final AtomicBoolean closed = new AtomicBoolean(); DummyMultiCommand() { - super("A dummy multi command", () -> {}); + super("A dummy multi command"); } @Override @@ -56,7 +56,7 @@ static class DummySubCommand extends Command { } DummySubCommand(final boolean throwsExceptionOnClose) { - super("A dummy subcommand", () -> {}); + super("A dummy subcommand"); this.throwsExceptionOnClose = throwsExceptionOnClose; } @@ -203,7 +203,7 @@ public void testCloseWhenSubCommandCloseThrowsException() throws Exception { static class ErrorThrowingSubCommand extends Command { ErrorThrowingSubCommand() { - super("error throwing", () -> {}); + super("error throwing"); } @Override diff --git a/x-pack/license-tools/src/main/java/org/elasticsearch/license/licensor/tools/KeyPairGeneratorTool.java b/x-pack/license-tools/src/main/java/org/elasticsearch/license/licensor/tools/KeyPairGeneratorTool.java index 6cfb3184e73be..f3fb13144bcc2 100644 --- a/x-pack/license-tools/src/main/java/org/elasticsearch/license/licensor/tools/KeyPairGeneratorTool.java +++ b/x-pack/license-tools/src/main/java/org/elasticsearch/license/licensor/tools/KeyPairGeneratorTool.java @@ -9,10 +9,10 @@ import joptsimple.OptionSet; import joptsimple.OptionSpec; +import org.elasticsearch.cli.Command; import org.elasticsearch.cli.ExitCodes; import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.UserException; -import org.elasticsearch.common.cli.LoggingAwareCommand; import org.elasticsearch.core.PathUtils; import org.elasticsearch.core.SuppressForbidden; @@ -24,7 +24,7 @@ import static org.elasticsearch.license.CryptUtils.writeEncryptedPrivateKey; -public class KeyPairGeneratorTool extends LoggingAwareCommand { +public class KeyPairGeneratorTool extends Command { private final OptionSpec publicKeyPathOption; private final OptionSpec privateKeyPathOption; diff --git a/x-pack/license-tools/src/main/java/org/elasticsearch/license/licensor/tools/LicenseGeneratorTool.java b/x-pack/license-tools/src/main/java/org/elasticsearch/license/licensor/tools/LicenseGeneratorTool.java index 4dc1b17b2f9f6..0d01772dca538 100644 --- a/x-pack/license-tools/src/main/java/org/elasticsearch/license/licensor/tools/LicenseGeneratorTool.java +++ b/x-pack/license-tools/src/main/java/org/elasticsearch/license/licensor/tools/LicenseGeneratorTool.java @@ -9,12 +9,12 @@ import joptsimple.OptionSet; import joptsimple.OptionSpec; +import org.elasticsearch.cli.Command; import org.elasticsearch.cli.ExitCodes; import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.UserException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; -import org.elasticsearch.common.cli.LoggingAwareCommand; import org.elasticsearch.core.PathUtils; import org.elasticsearch.core.SuppressForbidden; import org.elasticsearch.license.License; @@ -28,7 +28,7 @@ import java.nio.file.Files; import java.nio.file.Path; -public class LicenseGeneratorTool extends LoggingAwareCommand { +public class LicenseGeneratorTool extends Command { private final OptionSpec publicKeyPathOption; private final OptionSpec privateKeyPathOption; diff --git a/x-pack/license-tools/src/main/java/org/elasticsearch/license/licensor/tools/LicenseVerificationTool.java b/x-pack/license-tools/src/main/java/org/elasticsearch/license/licensor/tools/LicenseVerificationTool.java index 1059b100fc396..cdd2af97a3f16 100644 --- a/x-pack/license-tools/src/main/java/org/elasticsearch/license/licensor/tools/LicenseVerificationTool.java +++ b/x-pack/license-tools/src/main/java/org/elasticsearch/license/licensor/tools/LicenseVerificationTool.java @@ -9,12 +9,12 @@ import joptsimple.OptionSet; import joptsimple.OptionSpec; +import org.elasticsearch.cli.Command; import org.elasticsearch.cli.ExitCodes; import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.UserException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; -import org.elasticsearch.common.cli.LoggingAwareCommand; import org.elasticsearch.core.PathUtils; import org.elasticsearch.core.SuppressForbidden; import org.elasticsearch.license.CryptUtils; @@ -29,7 +29,7 @@ import java.nio.file.Files; import java.nio.file.Path; -public class LicenseVerificationTool extends LoggingAwareCommand { +public class LicenseVerificationTool extends Command { private final OptionSpec publicKeyPathOption; private final OptionSpec licenseOption; diff --git a/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/CertificateTool.java b/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/CertificateTool.java index 60c89c38ac889..4adf28a817c2c 100644 --- a/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/CertificateTool.java +++ b/x-pack/plugin/security/cli/src/main/java/org/elasticsearch/xpack/security/cli/CertificateTool.java @@ -22,12 +22,12 @@ import org.bouncycastle.pkcs.PKCS10CertificationRequest; import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.cli.ExitCodes; +import org.elasticsearch.cli.MultiCommand; import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.Terminal.Verbosity; import org.elasticsearch.cli.UserException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.cli.EnvironmentAwareCommand; -import org.elasticsearch.common.cli.LoggingAwareMultiCommand; import org.elasticsearch.common.network.InetAddresses; import org.elasticsearch.common.ssl.PemUtils; import org.elasticsearch.common.util.set.Sets; @@ -84,7 +84,7 @@ /** * CLI tool to make generation of certificates or certificate requests easier for users */ -class CertificateTool extends LoggingAwareMultiCommand { +class CertificateTool extends MultiCommand { private static final String AUTO_GEN_CA_DN = "CN=Elastic Certificate Tool Autogenerated CA"; private static final String DESCRIPTION = "Simplifies certificate creation for use with the Elastic Stack"; diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java index 06ec37daac416..bd858020b4dd4 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/tool/SetupPasswordTool.java @@ -12,13 +12,13 @@ import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.cli.ExitCodes; +import org.elasticsearch.cli.MultiCommand; import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.Terminal.Verbosity; import org.elasticsearch.cli.UserException; import org.elasticsearch.common.CheckedBiConsumer; import org.elasticsearch.common.Strings; import org.elasticsearch.common.cli.KeyStoreAwareCommand; -import org.elasticsearch.common.cli.LoggingAwareMultiCommand; import org.elasticsearch.common.settings.KeyStoreWrapper; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; @@ -72,7 +72,7 @@ * elastic user and the ChangePassword API for setting the password of the rest of the built-in users when needed. */ @Deprecated -class SetupPasswordTool extends LoggingAwareMultiCommand { +class SetupPasswordTool extends MultiCommand { private static final char[] CHARS = ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789").toCharArray(); public static final List USERS = asList( diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java index 09f542a8b2cdd..4f73f1c5f4107 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/file/tool/UsersTool.java @@ -11,11 +11,11 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.cli.ExitCodes; +import org.elasticsearch.cli.MultiCommand; import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.UserException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.cli.EnvironmentAwareCommand; -import org.elasticsearch.common.cli.LoggingAwareMultiCommand; import org.elasticsearch.common.settings.SecureString; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.Maps; @@ -43,7 +43,7 @@ import java.util.Set; import java.util.stream.Collectors; -class UsersTool extends LoggingAwareMultiCommand { +class UsersTool extends MultiCommand { UsersTool() { super("Manages elasticsearch file users"); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/service/FileTokensTool.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/service/FileTokensTool.java index 77d294b105a35..f865aa44aa2c1 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/service/FileTokensTool.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/service/FileTokensTool.java @@ -11,11 +11,11 @@ import joptsimple.OptionSpec; import org.elasticsearch.cli.ExitCodes; +import org.elasticsearch.cli.MultiCommand; import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.UserException; import org.elasticsearch.common.Strings; import org.elasticsearch.common.cli.EnvironmentAwareCommand; -import org.elasticsearch.common.cli.LoggingAwareMultiCommand; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.env.Environment; import org.elasticsearch.xpack.core.XPackSettings; @@ -31,7 +31,7 @@ import java.util.TreeMap; import java.util.function.Predicate; -class FileTokensTool extends LoggingAwareMultiCommand { +class FileTokensTool extends MultiCommand { FileTokensTool() { super("Manages elasticsearch service account file-tokens"); diff --git a/x-pack/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java b/x-pack/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java index 97d5bcc3da927..f780f4582803b 100644 --- a/x-pack/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java +++ b/x-pack/plugin/sql/sql-cli/src/main/java/org/elasticsearch/xpack/sql/cli/Cli.java @@ -85,7 +85,7 @@ private static void configureJLineLogging() { * Build the CLI. */ public Cli(CliTerminal cliTerminal) { - super("Elasticsearch SQL CLI", () -> {}); + super("Elasticsearch SQL CLI"); this.cliTerminal = cliTerminal; parser.acceptsAll(Arrays.asList("d", "debug"), "Enable debug logging"); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalTool.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalTool.java index 87711de6bc2a4..31f95a4b4adb5 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalTool.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/trigger/schedule/tool/CronEvalTool.java @@ -9,10 +9,10 @@ import joptsimple.OptionSet; import joptsimple.OptionSpec; +import org.elasticsearch.cli.Command; import org.elasticsearch.cli.ExitCodes; import org.elasticsearch.cli.Terminal; import org.elasticsearch.cli.UserException; -import org.elasticsearch.common.cli.LoggingAwareCommand; import org.elasticsearch.common.time.DateFormatter; import org.elasticsearch.xpack.core.scheduler.Cron; @@ -24,7 +24,7 @@ import java.util.List; import java.util.Locale; -class CronEvalTool extends LoggingAwareCommand { +class CronEvalTool extends Command { private static final DateFormatter UTC_FORMATTER = DateFormatter.forPattern("EEE, d MMM yyyy HH:mm:ss") .withZone(ZoneOffset.UTC)