ashb commented on code in PR #68725:
URL: https://github.com/apache/airflow/pull/68725#discussion_r3441831869
##########
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:
That example is broken and got truncated in my PR that I added. It _should
fail_ with an error, but a nice one.
--
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]