Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Substitute the equivalent for whichever agent was used. The convention is "visib

### Logging

Get loggers via `cosmos.log.get_logger`, not the stdlib `logging` module. This adds the `(astronomer-cosmos)` prefix when `rich_logging` is enabled and respects scoped log-level configuration.
In library / module-level code, get loggers via `cosmos.log.get_logger`, not the stdlib `logging` module. This adds the `(astronomer-cosmos)` prefix when `rich_logging` is enabled and respects scoped log-level configuration.

Yes:
```python
Expand All @@ -141,6 +141,12 @@ logger = logging.getLogger(__name__)
logging.error(...) # never call the root logger directly either
```

Inside operators, log via `self.log` (provided by Airflow's `LoggingMixin`) rather than a module-level logger, so messages land in the per-task-instance log shown in the Airflow UI:
```python
def execute(self, context):
self.log.info("Running command: %s", self.command)
```

Use **lazy logging**: pass the format string and arguments separately. Do not embed f-strings, `.format()`, or `%` interpolation in log messages — the logger formats them only when the record passes the level filter.

Yes:
Expand Down