uranusjr commented on code in PR #68725:
URL: https://github.com/apache/airflow/pull/68725#discussion_r3441869960
##########
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:
I’ll add some nicer errors.
The Python implementation currently also just use regex without error
handling. Should we improve it too?
https://github.com/apache/airflow/blob/d74fbff4e32108df9276c9a907536d7da710f8dc/shared/logging/src/airflow_shared/logging/structlog.py#L560-L564
--
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]