Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ const addLinks = (line: string) => {
return elements;
};

const sourceFields = ["logger", "chan"];

export const renderStructuredLog = ({
index,
logLevelFilters,
Expand Down Expand Up @@ -182,16 +184,21 @@ export const renderStructuredLog = ({
</chakra.span>,
);

if (showSource) {
for (const key in reStructured) {
if (Object.hasOwn(reStructured, key)) {
elements.push(
": ",
<chakra.span color={key === "logger" ? "fg.info" : undefined} key={`prop_${key}`}>
{key === "logger" ? "source" : key}={JSON.stringify(reStructured[key])}
</chakra.span>,
);
for (const key in reStructured) {
if (Object.hasOwn(reStructured, key)) {
if (!showSource && sourceFields.includes(key)) {
continue; // eslint-disable-line no-continue
}
const val = reStructured[key] as boolean | number | object | string | null;

elements.push(
" ",
<chakra.span color="fg.info" key={`prop_${key}`}>
{key === "logger" ? "source" : key}
</chakra.span>,
// Let strings, ints, etc through as is, but JSON stringify anything more complex
`=${val instanceof Object ? JSON.stringify(val) : val}`,
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe("Task log grouping", () => {
);

const summarySource = screen.getByTestId(
'summary-Log message source details: sources=["/home/airflow/logs/dag_id=tutorial_dag/run_id=manual__2025-02-28T05:18:54.249762+00:00/task_id=load/attempt=1.log"]',
'summary-Log message source details sources=["/home/airflow/logs/dag_id=tutorial_dag/run_id=manual__2025-02-28T05:18:54.249762+00:00/task_id=load/attempt=1.log"]',
);

expect(summarySource).toBeVisible();
Expand Down