phanikumv commented on code in PR #68725:
URL: https://github.com/apache/airflow/pull/68725#discussion_r3440383549


##########
java-sdk/sdk/src/main/kotlin/org/apache/airflow/sdk/execution/Logger.kt:
##########
@@ -34,52 +34,112 @@ import java.util.concurrent.ConcurrentLinkedDeque
 import kotlin.reflect.KClass
 import kotlin.time.Clock
 
-enum class Level { ERROR, DEBUG, }
+// Adapted from Python logging.
+enum class Level(
+  val value: Short,
+) {
+  CRITICAL(50),
+  ERROR(40),
+  WARNING(30),
+  INFO(20),
+  DEBUG(10),
+  NOTSET(0),
+}
+
+private object LevelParser {
+  val levels = Level.entries.map { it.toString().uppercase() to it }.toMap()
+
+  fun parse(s: String?) = levels[s?.uppercase()]
+
+  fun parseNamed(s: String?): Map<String, Level> {
+    if (s == null) return emptyMap()
+    return buildMap {
+      s.split(Regex("""[\s,]+""")).forEach {
+        val parts = it.split(Regex("""\s*=\s*"""), 2)
+        val level = parse(parts[1])
+        if (level != null) put(parts[0], level)

Review Comment:
   ```suggestion
           s.split(Regex("""[\s,]+""")).forEach {
             if (it.isEmpty()) return@forEach
             val parts = it.split(Regex("""\s*=\s*"""), 2)
             if (parts.size != 2) return@forEach // <- guards parts[1]
             val level = parse(parts[1])
             if (level != null) put(parts[0], level)
           }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to