Skip to content

Commit 55a0943

Browse files
committed
TIKA-4809: Rename logLevel, drop the no-op -a flag, fix --help exit, delete orphan config
1 parent 5add0fa commit 55a0943

5 files changed

Lines changed: 18 additions & 86 deletions

File tree

docs/modules/ROOT/pages/using-tika/server/index.adoc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,8 @@ The server starts on `localhost:9998` by default.
9292
|`-c <file>` or `--config <file>`
9393
|Path to `tika-config.json`. See <<_configuration,Configuration>> below.
9494

95-
|`-a <file>` or `--pluginsConfig <file>`
96-
|Path to the Tika Pipes plugins configuration file.
97-
9895
|`-i <id>` or `--id <id>`
99-
|Server ID, surfaced in the `/status` endpoint and in logs.
96+
|Server ID, written to the startup log. Defaults to a random UUID.
10097

10198
|`-?` or `--help`
10299
|Print the usage message.
@@ -182,7 +179,7 @@ curl -T document.pdf http://localhost:9998/meta/Content-Type # single field
182179
=== Other endpoints
183180

184181
* `/version` — server version
185-
* `/status` — health/status (includes server ID)
182+
* `/status` — health/status: state, active task count, files processed
186183
* `/parsers` and `/parsers/details` — registered parsers
187184
* `/detectors` — registered detectors
188185
* `/mime-types` — known MIME types

tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerCli.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ private static Options getOptions() {
4343
"listen port (default = 9998)\n");
4444
options.addOption("?", "help", false, "this help message");
4545
options.addOption("c", "config", true, "tika-config file");
46-
options.addOption("a", "pluginsConfig", true, "tike pipes config");
47-
4846
options.addOption("i", "id", true, "id to use for server in" + " the server status endpoint and logging");
4947
return options;
5048
}
@@ -69,7 +67,7 @@ public static void main(String[] args) {
6967
private static void usage(Options options) throws IOException {
7068
HelpFormatter helpFormatter = HelpFormatter.builder().get();
7169
helpFormatter.printHelp("tikaserver", null, options, null, true);
72-
System.exit(-1);
70+
System.exit(0);
7371
}
7472

7573
}

tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerConfig.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public class TikaServerConfig {
3939

4040
public static final int DEFAULT_PORT = 9998;
4141
public static final String DEFAULT_HOST = "localhost";
42-
public static final Set<String> LOG_LEVELS = new HashSet<>(Arrays.asList("debug", "info"));
4342
private static final Logger LOG = LoggerFactory.getLogger(TikaServerConfig.class);
4443
/**
4544
* Endpoints that expose the pipes/fetch machinery (process-isolated pipes
@@ -75,8 +74,7 @@ public class TikaServerConfig {
7574
.toString();
7675
private int port = DEFAULT_PORT;
7776
private String host = DEFAULT_HOST;
78-
//debug or info only
79-
private String logLevel = "";
77+
private String requestLogLevel = "";
8078
private Path configPath;
8179
private ArrayList<String> endpoints = new ArrayList<>();
8280

@@ -93,7 +91,6 @@ public static TikaServerConfig load(CommandLine commandLine) throws IOException,
9391

9492
TikaServerConfig config = null;
9593
Set<String> settings = new HashSet<>();
96-
Path pluginsConfig = null;
9794

9895
if (commandLine.hasOption("c")) {
9996
config = load(Paths.get(commandLine.getOptionValue("c")), commandLine, settings);
@@ -201,15 +198,19 @@ public void setHost(String host) {
201198
this.host = host;
202199
}
203200

204-
public String getLogLevel() {
205-
return logLevel;
201+
/**
202+
* Severity at which each request URI is logged. Empty (the default) disables
203+
* request logging entirely; this does not change the log level of anything else.
204+
*/
205+
public String getRequestLogLevel() {
206+
return requestLogLevel;
206207
}
207208

208-
public void setLogLevel(String level) throws TikaConfigException {
209+
public void setRequestLogLevel(String level) throws TikaConfigException {
209210
if (level.equals("debug") || level.equals("info")) {
210-
this.logLevel = level;
211+
this.requestLogLevel = level;
211212
} else {
212-
throw new TikaConfigException("log level must be one of: 'debug' or 'info'");
213+
throw new TikaConfigException("requestLogLevel must be one of: 'debug' or 'info'");
213214
}
214215
}
215216

tika-server/tika-server-core/src/main/java/org/apache/tika/server/core/TikaServerProcess.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@
2222
import java.nio.file.Path;
2323
import java.security.GeneralSecurityException;
2424
import java.util.ArrayList;
25-
import java.util.Arrays;
2625
import java.util.Collection;
2726
import java.util.Collections;
2827
import java.util.HashMap;
29-
import java.util.HashSet;
3028
import java.util.List;
3129
import java.util.Map;
32-
import java.util.Set;
3330

3431
import org.apache.commons.cli.CommandLine;
3532
import org.apache.commons.cli.CommandLineParser;
@@ -100,7 +97,6 @@
10097
public class TikaServerProcess {
10198

10299

103-
public static final Set<String> LOG_LEVELS = new HashSet<>(Arrays.asList("debug", "info"));
104100
public static final int BIND_EXCEPTION = 42;
105101
private static final Logger LOG = LoggerFactory.getLogger(TikaServerProcess.class);
106102
public static int DO_NOT_RESTART_EXIT_VALUE = -100;
@@ -110,7 +106,6 @@ private static Options getOptions() {
110106
options.addOption("h", "host", true, "host name, use * for all)");
111107
options.addOption("p", "port", true, "listen port");
112108
options.addOption("c", "config", true, "Tika Configuration xml file to override default config with.");
113-
options.addOption("a", "pluginsConfig", true, "Tika Configuration json for pluginscomponents");
114109
options.addOption("i", "id", true, "id to use for server in server status endpoint");
115110
options.addOption("?", "help", false, "this help message");
116111
return options;
@@ -316,16 +311,12 @@ private static void loadAllProviders(TikaServerConfig tikaServerConfig, ServerSt
316311
// Add ConfigEndpointSecurityFilter to gate /config endpoints
317312
writers.add(new ConfigEndpointSecurityFilter(tikaServerConfig.isAllowPerRequestConfig()));
318313

314+
// setRequestLogLevel rejects anything but debug/info, so no validation needed here.
319315
TikaLoggingFilter logFilter = null;
320-
if (!StringUtils.isBlank(tikaServerConfig.getLogLevel())) {
321-
String logLevel = tikaServerConfig.getLogLevel();
322-
if (LOG_LEVELS.contains(logLevel)) {
323-
boolean isInfoLevel = "info".equals(logLevel);
324-
logFilter = new TikaLoggingFilter(isInfoLevel);
325-
writers.add(logFilter);
326-
} else {
327-
LOG.warn("Unsupported request URI log level: {}", logLevel);
328-
}
316+
String requestLogLevel = tikaServerConfig.getRequestLogLevel();
317+
if (!StringUtils.isBlank(requestLogLevel)) {
318+
logFilter = new TikaLoggingFilter("info".equals(requestLogLevel));
319+
writers.add(logFilter);
329320
}
330321

331322
CrossOriginResourceSharingFilter corsFilter = null;

tika-server/tika-server-core/src/main/resources/tika-server-config-default.xml

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)