You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apex.apache.org by th...@apache.org on 2017/08/17 15:34:46 UTC
[apex-core] branch master updated: APEXCORE-670 Add command to set
logLevel in CLI
This is an automated email from the ASF dual-hosted git repository.
thw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apex-core.git
The following commit(s) were added to refs/heads/master by this push:
new 760b0e7 APEXCORE-670 Add command to set logLevel in CLI
760b0e7 is described below
commit 760b0e77cb8bf524e3dd17afd8684e4896f358ca
Author: Florian Schmidt <fl...@icloud.com>
AuthorDate: Wed Jul 26 13:22:11 2017 -0700
APEXCORE-670 Add command to set logLevel in CLI
Usage could either be
apex>set-log-level application_1499808956620_0873 org.apache.apex.examples.pi.PiCalculateOperator TRACE
or when already connected to an app:
apex (application_1499808956620_0873) >set-log-level org.apache.apex.examples.pi.PiCalculateOperator TRACE
---
.../java/com/datatorrent/stram/cli/ApexCli.java | 48 ++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java b/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java
index 903dad2..1717ace 100644
--- a/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java
+++ b/engine/src/main/java/com/datatorrent/stram/cli/ApexCli.java
@@ -810,6 +810,10 @@ public class ApexCli
null,
new Arg[]{new Arg("container-id")},
"Get the stack trace for the container"));
+ connectedCommands.put("set-log-level", new CommandSpec(new SetLogLevelCommand(),
+ new Arg[]{new Arg("target"), new Arg("logLevel")},
+ null,
+ "Set the logging level of any package or class of the connected app instance"));
//
// Logical plan change command specification starts here
@@ -3988,6 +3992,50 @@ public class ApexCli
}
}
+ private class SetLogLevelCommand implements Command
+ {
+
+ @Override
+ public void execute(String[] args, ConsoleReader reader) throws Exception
+ {
+ ApplicationReport appReport = currentApp;
+ String target = args[1];
+ String logLevel = args[2];
+
+ StramAgent.StramUriSpec uriSpec = new StramAgent.StramUriSpec();
+ uriSpec = uriSpec.path(StramWebServices.PATH_LOGGERS);
+ final JSONObject request = buildRequest(target, logLevel);
+
+ JSONObject response = getResource(uriSpec, appReport, new WebServicesClient.WebServicesHandler<JSONObject>()
+ {
+ @Override
+ public JSONObject process(WebResource.Builder webResource, Class<JSONObject> clazz)
+ {
+ return webResource.accept(MediaType.APPLICATION_JSON).post(JSONObject.class, request);
+ }
+
+ });
+
+ printJson(response);
+ }
+
+ private JSONObject buildRequest(String target, String logLevel) throws JSONException
+ {
+ JSONObject request = new JSONObject();
+ JSONArray loggers = new JSONArray();
+ JSONObject targetAndLevelPair = new JSONObject();
+
+ targetAndLevelPair.put("target", target);
+ targetAndLevelPair.put("logLevel", logLevel);
+
+ loggers.put(targetAndLevelPair);
+
+ request.put("loggers", loggers);
+
+ return request;
+ }
+ }
+
@SuppressWarnings("static-access")
public static class GetPhysicalPropertiesCommandLineOptions
{
--
To stop receiving notification emails like this one, please contact
['"commits@apex.apache.org" <co...@apex.apache.org>'].