aboutsummaryrefslogtreecommitdiffstats
path: root/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Tests/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/SmartColorDiscriminator.kt
diff options
context:
space:
mode:
Diffstat (limited to 'components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Tests/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/SmartColorDiscriminator.kt')
-rw-r--r--components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Tests/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/SmartColorDiscriminator.kt24
1 files changed, 24 insertions, 0 deletions
diff --git a/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Tests/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/SmartColorDiscriminator.kt b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Tests/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/SmartColorDiscriminator.kt
new file mode 100644
index 000000000..47987010c
--- /dev/null
+++ b/components/model-catalog/blueprint-model/archetype-blueprint/src/main/resources/archetype-resources/Tests/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/uat/logging/SmartColorDiscriminator.kt
@@ -0,0 +1,24 @@
+package org.onap.ccsdk.cds.blueprintsprocessor.uat.logging
+
+import ch.qos.logback.classic.spi.ILoggingEvent
+import ch.qos.logback.core.sift.AbstractDiscriminator
+import org.onap.ccsdk.cds.blueprintsprocessor.uat.logging.ColorMarker
+import org.onap.ccsdk.cds.blueprintsprocessor.uat.logging.LogColor.MDC_COLOR_KEY
+
+class SmartColorDiscriminator : AbstractDiscriminator<ILoggingEvent>() {
+
+ var defaultValue: String = "white"
+
+ override fun getKey(): String {
+ return MDC_COLOR_KEY
+ }
+
+ fun setKey() {
+ throw UnsupportedOperationException("Key not settable. Using $MDC_COLOR_KEY")
+ }
+
+ override fun getDiscriminatingValue(e: ILoggingEvent): String =
+ (e.marker as? ColorMarker)?.name
+ ?: e.mdcPropertyMap?.get(MDC_COLOR_KEY)
+ ?: defaultValue
+}