aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Application.java8
-rw-r--r--tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Application.java8
-rw-r--r--tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/Application.java36
-rw-r--r--tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java3
-rw-r--r--tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java10
5 files changed, 53 insertions, 12 deletions
diff --git a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Application.java b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Application.java
index 236750310..b6c6b774c 100644
--- a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Application.java
+++ b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2cli/Application.java
@@ -26,6 +26,8 @@ import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.tools.common.CliOptions;
import org.onap.policy.apex.tools.common.CliParser;
import org.onap.policy.apex.tools.common.OutputFile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Process an Apex Policy Model file to generate the CLI commands to generate an equivalent Apex Policy Model.
@@ -33,6 +35,8 @@ import org.onap.policy.apex.tools.common.OutputFile;
* @author Sven van der Meer <sven.van.der.meer@ericsson.com>
*/
public final class Application {
+ // Get a reference to the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);
/** The name of the application. */
public static final String APP_NAME = "gen-model2cli";
@@ -118,7 +122,9 @@ public final class Application {
final Model2Cli app = new Model2Cli(modelFile, outfile, !cmd.hasOption("sv"), APP_NAME);
app.runApp();
} catch (final ApexException aex) {
- System.err.println(APP_NAME + ": caught APEX exception with message: " + aex.getMessage());
+ String message = APP_NAME + ": caught APEX exception with message: " + aex.getMessage();
+ System.err.println(message);
+ LOGGER.warn(message, aex);
}
}
}
diff --git a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Application.java b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Application.java
index 2bc70f69e..9735293cf 100644
--- a/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Application.java
+++ b/tools/model-generator/src/main/java/org/onap/policy/apex/tools/model/generator/model2event/Application.java
@@ -25,6 +25,8 @@ import org.apache.commons.cli.HelpFormatter;
import org.onap.policy.apex.model.basicmodel.concepts.ApexException;
import org.onap.policy.apex.tools.common.CliOptions;
import org.onap.policy.apex.tools.common.CliParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Model 2 event generator with main method.
@@ -32,6 +34,8 @@ import org.onap.policy.apex.tools.common.CliParser;
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
public final class Application {
+ // Get a reference to the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);
/** The name of the application. */
public static final String APP_NAME = "gen-model2event";
@@ -105,7 +109,9 @@ public final class Application {
final Model2JsonEventSchema app = new Model2JsonEventSchema(modelFile, type, APP_NAME);
app.runApp();
} catch (final ApexException aex) {
- System.err.println(APP_NAME + ": caught APEX exception with message: " + aex.getMessage());
+ String message = APP_NAME + ": caught APEX exception with message: " + aex.getMessage();
+ System.err.println(message);
+ LOGGER.warn(message, aex);
}
}
}
diff --git a/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/Application.java b/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/Application.java
index bfd6573bc..7c7d7e9c6 100644
--- a/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/Application.java
+++ b/tools/simple-wsclient/src/main/java/org/onap/policy/apex/tools/simple/wsclient/Application.java
@@ -29,6 +29,8 @@ import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.lang3.Validate;
import org.onap.policy.apex.tools.common.CliOptions;
import org.onap.policy.apex.tools.common.CliParser;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Simple console application with main method.
@@ -36,6 +38,8 @@ import org.onap.policy.apex.tools.common.CliParser;
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
public final class Application {
+ // Get a reference to the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);
/**
* Private constructor prevents subclassing.
@@ -133,11 +137,17 @@ public final class Application {
final SimpleEcho simpleEcho = new SimpleEcho(server, port, appName);
simpleEcho.connect();
} catch (final URISyntaxException uex) {
- System.err.println(appName + ": URI exception, could not create URI from server and port settings");
+ String message = appName + ": URI exception, could not create URI from server and port settings";
+ System.err.println(message);
+ LOGGER.warn(message, uex);
} catch (final NullPointerException nex) {
- System.err.println(appName + ": null pointer, server or port were null");
+ String message = appName + ": null pointer, server or port were null";
+ System.err.println(message);
+ LOGGER.warn(message, nex);
} catch (final IllegalArgumentException iex) {
- System.err.println(appName + ": illegal argument, server or port were blank");
+ String message = appName + ": illegal argument, server or port were blank";
+ System.err.println(message);
+ LOGGER.warn(message, iex);
}
}
@@ -167,15 +177,25 @@ public final class Application {
final SimpleConsole simpleConsole = new SimpleConsole(server, port, appName);
simpleConsole.runClient();
} catch (final URISyntaxException uex) {
- System.err.println(appName + ": URI exception, could not create URI from server and port settings");
+ String message = appName + ": URI exception, could not create URI from server and port settings";
+ System.err.println(message);
+ LOGGER.warn(message, uex);
} catch (final NullPointerException nex) {
- System.err.println(appName + ": null pointer, server or port were null");
+ String message = appName + ": null pointer, server or port were null";
+ System.err.println(message);
+ LOGGER.warn(message, nex);
} catch (final IllegalArgumentException iex) {
- System.err.println(appName + ": illegal argument, server or port were blank");
+ String message = appName + ": illegal argument, server or port were blank";
+ System.err.println(message);
+ LOGGER.warn(message, iex);
} catch (final NotYetConnectedException nex) {
- System.err.println(appName + ": not yet connected, connection to server took too long");
+ String message = appName + ": not yet connected, connection to server took too long";
+ System.err.println(message);
+ LOGGER.warn(message, nex);
} catch (final IOException ioe) {
- System.err.println(appName + ": IO exception, something went wrong on the standard input");
+ String message = appName + ": IO exception, something went wrong on the standard input";
+ System.err.println(message);
+ LOGGER.warn(message, ioe);
}
}
}
diff --git a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java
index 28337fdeb..aacc22013 100644
--- a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java
+++ b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/Console.java
@@ -25,6 +25,8 @@ import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StrBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.slf4j.ext.XLoggerFactory;
import org.slf4j.helpers.MessageFormatter;
@@ -36,7 +38,6 @@ import org.slf4j.helpers.MessageFormatter;
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
public final class Console {
-
/** The console as static object. */
public static final Console CONSOLE = new Console();
diff --git a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java
index b529a7e08..59d15d19d 100644
--- a/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java
+++ b/tools/tools-common/src/main/java/org/onap/policy/apex/tools/common/OutputFile.java
@@ -32,6 +32,8 @@ import java.nio.file.Path;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Standard output file handling and tests.
@@ -39,6 +41,8 @@ import org.apache.commons.lang3.Validate;
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
public class OutputFile {
+ // Get a reference to the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(OutputFile.class);
/** The output file name. */
private final String fileName;
@@ -86,6 +90,7 @@ public class OutputFile {
try {
return new BufferedWriter(new FileWriter(toFile()));
} catch (final IOException e) {
+ LOGGER.warn("write error", e);
return null;
}
}
@@ -99,6 +104,7 @@ public class OutputFile {
try {
return new FileOutputStream(toFile());
} catch (final IOException e) {
+ LOGGER.warn("stream creation error", e);
return null;
}
}
@@ -123,7 +129,9 @@ public class OutputFile {
try {
file.createNewFile();
} catch (final IOException e) {
- return "could not create output file: " + e.getMessage();
+ String message = "could not create output file: " + e.getMessage();
+ LOGGER.warn(message, e);
+ return message;
}
}