summaryrefslogtreecommitdiffstats
path: root/hv-collector-utils/src
diff options
context:
space:
mode:
Diffstat (limited to 'hv-collector-utils/src')
-rw-r--r--hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/CommandLineOption.kt14
-rw-r--r--hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/logging/Logger.kt25
-rw-r--r--hv-collector-utils/src/test/kotlin/org/onap/dcae/collectors/veshv/utils/logging/LoggerTest.kt44
3 files changed, 83 insertions, 0 deletions
diff --git a/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/CommandLineOption.kt b/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/CommandLineOption.kt
index d36f194d..9d1f7aa8 100644
--- a/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/CommandLineOption.kt
+++ b/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/commandline/CommandLineOption.kt
@@ -55,6 +55,20 @@ enum class CommandLineOption(val option: Option) {
.desc("Amount of messages to send")
.build()
),
+ KAFKA_SERVERS(Option.builder("s")
+ .longOpt("kafka-bootstrap-servers")
+ .required()
+ .hasArg()
+ .desc("Comma-separated Kafka bootstrap servers in <host>:<port> format")
+ .build()
+ ),
+ KAFKA_TOPICS(Option.builder("f")
+ .longOpt("kafka-topics")
+ .required()
+ .hasArg()
+ .desc("Comma-separated Kafka topics")
+ .build()
+ ),
PRIVATE_KEY_FILE(Option.builder("k")
.longOpt("private-key-file")
.hasArg()
diff --git a/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/logging/Logger.kt b/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/logging/Logger.kt
index 314c9bf9..19bfa126 100644
--- a/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/logging/Logger.kt
+++ b/hv-collector-utils/src/main/kotlin/org/onap/dcae/collectors/veshv/utils/logging/Logger.kt
@@ -107,4 +107,29 @@ class Logger(val logger: org.slf4j.Logger) {
logger.warn(messageProvider(), ex)
}
}
+
+
+ //
+ // ERROR
+ //
+
+ fun error(message: String) {
+ logger.error(message)
+ }
+
+ fun error(message: String, ex: Exception) {
+ logger.error(message, ex)
+ }
+
+ fun error(messageProvider: () -> String) {
+ if (logger.isErrorEnabled) {
+ logger.error(messageProvider())
+ }
+ }
+
+ fun error(ex: Exception, messageProvider: () -> String) {
+ if (logger.isErrorEnabled) {
+ logger.error(messageProvider(), ex)
+ }
+ }
}
diff --git a/hv-collector-utils/src/test/kotlin/org/onap/dcae/collectors/veshv/utils/logging/LoggerTest.kt b/hv-collector-utils/src/test/kotlin/org/onap/dcae/collectors/veshv/utils/logging/LoggerTest.kt
index be521970..b98131cc 100644
--- a/hv-collector-utils/src/test/kotlin/org/onap/dcae/collectors/veshv/utils/logging/LoggerTest.kt
+++ b/hv-collector-utils/src/test/kotlin/org/onap/dcae/collectors/veshv/utils/logging/LoggerTest.kt
@@ -181,6 +181,50 @@ object LoggerTest : Spek({
}
}
+ describe("error levels") {
+ it("should log message") {
+ cut.error(message)
+ verify(slf4jLogger).error(message)
+ }
+
+ it("should log message with exception") {
+ cut.error(message, exception)
+ verify(slf4jLogger).error(message, exception)
+ }
+
+ describe("lazy logging message") {
+
+ it("should log when debug is ON") {
+ whenever(slf4jLogger.isErrorEnabled).thenReturn(true)
+ cut.error { message }
+ verify(slf4jLogger).isErrorEnabled
+ verify(slf4jLogger).error(message)
+ }
+
+ it("should not log when debug is OFF") {
+ whenever(slf4jLogger.isErrorEnabled).thenReturn(false)
+ cut.error { message }
+ verify(slf4jLogger).isErrorEnabled
+ }
+ }
+
+ describe("lazy logging message with exception") {
+
+ it("should log when debug is ON") {
+ whenever(slf4jLogger.isErrorEnabled).thenReturn(true)
+ cut.error(exception) { message }
+ verify(slf4jLogger).isErrorEnabled
+ verify(slf4jLogger).error(message, exception)
+ }
+
+ it("should not log when debug is OFF") {
+ whenever(slf4jLogger.isErrorEnabled).thenReturn(false)
+ cut.error(exception) { message }
+ verify(slf4jLogger).isErrorEnabled
+ }
+ }
+ }
+
}
})