jason810496 commented on code in PR #71882:
URL: https://github.com/apache/airflow/pull/71882#discussion_r3826852818
##########
go-sdk/README.md:
##########
@@ -202,6 +202,17 @@ func extract(ctx sdk.TIRunContext, log *slog.Logger) (any,
error) {
`TryNumber`; `ctx.DagRun()` returns `DagID`, `RunID`, and the `*time.Time`
fields `LogicalDate`,
`DataIntervalStart`, and `DataIntervalEnd` (nil when the run has no such
value, e.g. a manual trigger).
+### Task logging
+
+In coordinator mode, the injected logger filters records using Airflow's
configured `[logging] logging_level` before sending them to the supervisor.
Airflow also propagates `[logging] namespace_levels`; because `slog` does not
have named loggers, bind the namespace as the top-level `logger` attribute:
+
+```go
+databaseLog := log.With("logger", "example.database")
+databaseLog.Debug("query complete", "rows", 42)
+```
+
+Namespace levels use longest dotted-prefix matching, so an `example=DEBUG`
override also applies to `example.database` unless a more specific override
takes precedence.
Review Comment:
Addressed in 2f7de6c440 . Agreed, it makes more sense to leverage the
`WithGroup` for the namespace level logging config from Airflow side.
##########
go-sdk/pkg/execution/logger.go:
##########
@@ -134,6 +259,16 @@ func (h *SocketLogHandler) Handle(_ context.Context, r
slog.Record) error {
return true
})
+ loggerName, _ := entry["logger"].(string)
+ if !h.filter.isEnabled(loggerName, r.Level) {
+ return nil
+ }
+ levelName, ok := getAirflowLogLevelName(r.Level)
+ if !ok {
+ return nil
+ }
Review Comment:
Addressed in 97c2341afb by normalizing custom slog levels to supported
Airflow levels.
--
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]