Skip to content

Ensure that filename and lineno of logger calls are present in the Task Logs#55581

Merged
kaxil merged 1 commit intoapache:mainfrom
astronomer:update-task-log-caller-info
Sep 15, 2025
Merged

Ensure that filename and lineno of logger calls are present in the Task Logs#55581
kaxil merged 1 commit intoapache:mainfrom
astronomer:update-task-log-caller-info

Conversation

@ashb
Copy link
Copy Markdown
Member

@ashb ashb commented Sep 12, 2025

This was present in 2.x (and earlier) in the default config which most people
left as is. This brings the information back (though displayed in task logs in
a different format)

Additionally, although the log_format config is not respected for the
display, we do examine it to see if any of the other "callsite parameters" (as
structlog calls them) such as processName or process (the pid) are
present, and if they are, those will be recorded in the JSON task logs too.

As part of this, the already-ignored (since #52651) colored_log_format has
been removed from the config so it doesn't show up in the docs.

THe "Toggle Source" option in the front end now also hides the "loc" (short
for location. Maybe should be localized? Ditto with "source" though) field. I
also added a unit test to the "Toggle Source" in the front end which wasn't
covered by any unit tests.

Some screenshots of what it looks like:

Where it appears in task logs (orange line is a highlight in the screenshot, not the real thing)

Screenshot 2025-09-11 at 18 49 57

When "Toggle Source" is turned off, both source and loc are hidden.

Screenshot 2025-09-12 at 17 22 14

When a celery worker is run with AIRFLOW__LOGGING__LOG_FORMAT='[%(asctime)s] {%(filename)s:%(lineno)d %(processName)s} %(levelname)s - %(message)s' we see process_name in the output logs
Screenshot 2025-09-12 at 17 11 14

Fixes #54145

Closes #54433


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@ashb ashb requested a review from kaxil as a code owner September 12, 2025 16:17
@ashb ashb added this to the Airflow 3.1.0 milestone Sep 12, 2025
@boring-cyborg boring-cyborg bot added area:ConfigTemplates area:logging area:task-sdk area:UI Related to UI/UX. For Frontend Developers. labels Sep 12, 2025
@ashb ashb force-pushed the update-task-log-caller-info branch 2 times, most recently from 7c6d656 to 39be1aa Compare September 13, 2025 07:17
@eladkal

This comment was marked as resolved.

@ashb ashb force-pushed the update-task-log-caller-info branch 2 times, most recently from 8c2a4ea to 024b1a5 Compare September 15, 2025 11:03
…sk Logs

This was present in 2.x (and earlier) in the default config which most people
left as is. This brings the information back (though displayed in task logs in
a different format)

Additionally, although the `log_format` config is not respected for the
display, we do examine it to see if any of the other "callsite parameters" (as
structlog calls them) such as `processName` or `process` (the pid) are
present, and if they are, those will be recorded in the JSON task logs too.

As part of this, the already-ignored (since apache#52651) colored_log_format has
been removed from the config so it doesn't show up in the docs.

THe "Toggle Source" option in the front end now also hides the "loc" (short
for location. Maybe should be localized? Ditto with "source" though) field. I
also added a unit test to the "Toggle Source" in the front end which wasn't
covered by any unit tests.

Fixes apache#54145
@ashb ashb force-pushed the update-task-log-caller-info branch from 024b1a5 to 31bde20 Compare September 15, 2025 17:57
@kaxil kaxil merged commit 6801bca into apache:main Sep 15, 2025
108 checks passed
@kaxil kaxil deleted the update-task-log-caller-info branch September 15, 2025 18:52
kaxil pushed a commit that referenced this pull request Sep 15, 2025
…sk Logs (#55581)

This was present in 2.x (and earlier) in the default config which most people
left as is. This brings the information back (though displayed in task logs in
a different format)

Additionally, although the `log_format` config is not respected for the
display, we do examine it to see if any of the other "callsite parameters" (as
structlog calls them) such as `processName` or `process` (the pid) are
present, and if they are, those will be recorded in the JSON task logs too.

As part of this, the already-ignored (since #52651) colored_log_format has
been removed from the config so it doesn't show up in the docs.

THe "Toggle Source" option in the front end now also hides the "loc" (short
for location. Maybe should be localized? Ditto with "source" though) field. I
also added a unit test to the "Toggle Source" in the front end which wasn't
covered by any unit tests.

Fixes #54145

(cherry picked from commit 6801bca)
yash1thsa pushed a commit to yash1thsa/airflow that referenced this pull request Sep 16, 2025
…sk Logs (apache#55581)

This was present in 2.x (and earlier) in the default config which most people
left as is. This brings the information back (though displayed in task logs in
a different format)

Additionally, although the `log_format` config is not respected for the
display, we do examine it to see if any of the other "callsite parameters" (as
structlog calls them) such as `processName` or `process` (the pid) are
present, and if they are, those will be recorded in the JSON task logs too.

As part of this, the already-ignored (since apache#52651) colored_log_format has
been removed from the config so it doesn't show up in the docs.

THe "Toggle Source" option in the front end now also hides the "loc" (short
for location. Maybe should be localized? Ditto with "source" though) field. I
also added a unit test to the "Toggle Source" in the front end which wasn't
covered by any unit tests.

Fixes apache#54145
suman-himanshu pushed a commit to suman-himanshu/airflow that referenced this pull request Sep 17, 2025
…sk Logs (apache#55581)

This was present in 2.x (and earlier) in the default config which most people
left as is. This brings the information back (though displayed in task logs in
a different format)

Additionally, although the `log_format` config is not respected for the
display, we do examine it to see if any of the other "callsite parameters" (as
structlog calls them) such as `processName` or `process` (the pid) are
present, and if they are, those will be recorded in the JSON task logs too.

As part of this, the already-ignored (since apache#52651) colored_log_format has
been removed from the config so it doesn't show up in the docs.

THe "Toggle Source" option in the front end now also hides the "loc" (short
for location. Maybe should be localized? Ditto with "source" though) field. I
also added a unit test to the "Toggle Source" in the front end which wasn't
covered by any unit tests.

Fixes apache#54145
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:logging area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logs no longer show the call site file and line number

3 participants