From 2fcc723d66f4779048c3836f13bcce648c2c464b Mon Sep 17 00:00:00 2001 From: Pete Gadomski Date: Tue, 16 Dec 2025 06:09:50 -0700 Subject: [PATCH 1/2] feat: query and answer logging --- backend/Dockerfile | 17 ++++++++-------- backend/logging.yaml | 31 ++++++++++++++++++++++++++++++ backend/src/atlas_assistant/api.py | 5 ++++- docker-compose.yml | 3 +++ terraform/aws/ecs.tf | 6 ++++-- 5 files changed, 51 insertions(+), 11 deletions(-) create mode 100644 backend/logging.yaml diff --git a/backend/Dockerfile b/backend/Dockerfile index f4a9ce8..3bb85d0 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -17,20 +17,21 @@ RUN --mount=type=cache,target=/root/.cache/uv \ --mount=type=bind,source=uv.lock,target=uv.lock \ --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ uv sync \ - --frozen \ - --no-dev \ - --no-editable \ - --no-install-project + --frozen \ + --no-dev \ + --no-editable \ + --no-install-project COPY src /app/src COPY data /app/data +COPY logging.yaml /app/logging.yaml RUN --mount=type=cache,target=/root/.cache/uv \ uv sync \ - --frozen \ - --no-dev \ - --no-editable \ - --compile-bytecode + --frozen \ + --no-dev \ + --no-editable \ + --compile-bytecode ################################### # DEVELOPMENT (--target local) diff --git a/backend/logging.yaml b/backend/logging.yaml new file mode 100644 index 0000000..ab4389f --- /dev/null +++ b/backend/logging.yaml @@ -0,0 +1,31 @@ +version: 1 +disable_existing_loggers: false + +formatters: + default: + format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s" + datefmt: "%Y-%m-%d %H:%M:%S" + +handlers: + console: + class: logging.StreamHandler + formatter: default + stream: ext://sys.stdout + +loggers: + uvicorn: + level: INFO + handlers: + - console + propagate: false + + atlas_assistant: + level: INFO + handlers: + - console + propagate: false + +root: + level: INFO + handlers: + - console diff --git a/backend/src/atlas_assistant/api.py b/backend/src/atlas_assistant/api.py index 03ae45d..15ab16d 100644 --- a/backend/src/atlas_assistant/api.py +++ b/backend/src/atlas_assistant/api.py @@ -208,6 +208,7 @@ async def chat( agent: Agent = request.state.agent thread_id = chat_request.thread_id or str(uuid.uuid4()) event_stream = (accept and "text/event-stream" in accept) or False + logger.info(f"Query: {chat_request.query}") return StreamingResponse( query_agent(agent, chat_request.query, thread_id, settings, event_stream), media_type="text/event-stream" if event_stream else "application/x-ndjson", @@ -262,8 +263,10 @@ def maybe_create_response_message( for tool_call in tool_calls: function = tool_call.get("function") if function.get("name") == "Output": + output = Output.model_validate_json(function.get("arguments")) + logger.info(f"Answer: {output.answer}") return OutputResponseMessage( - output=Output.model_validate_json(function.get("arguments")), + output=output, thread_id=thread_id, ) if message.content: diff --git a/docker-compose.yml b/docker-compose.yml index 24f0f8e..544d20f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,12 +16,15 @@ services: "*data*", "--host", "0.0.0.0", + "--log-config", + "logging.yaml", ] volumes: - ./backend/.env:/app/.env - ./backend/src:/app/src - ./backend/data:/app/data - ./backend/tests:/app/tests + - ./backend/logging.yaml:/app/logging.yaml chat: image: atlas/backend diff --git a/terraform/aws/ecs.tf b/terraform/aws/ecs.tf index 106feaf..4dbc4f4 100644 --- a/terraform/aws/ecs.tf +++ b/terraform/aws/ecs.tf @@ -43,7 +43,9 @@ module "ecs" { "--host", "0.0.0.0", "--port", - "8000" + "8000", + "--log-config", + "logging.yaml" ] portMappings = [ { @@ -88,4 +90,4 @@ module "ecs" { } tags = var.tags -} \ No newline at end of file +} From 0cc8dbcd3ee0eacc0948c188bd98e3f86025e074 Mon Sep 17 00:00:00 2001 From: aliziel <21992503+aliziel@users.noreply.github.com> Date: Thu, 18 Dec 2025 11:54:13 -0800 Subject: [PATCH 2/2] fix: allow logging.yaml in docker build --- backend/.dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/.dockerignore b/backend/.dockerignore index 03a89fc..8551df2 100644 --- a/backend/.dockerignore +++ b/backend/.dockerignore @@ -6,6 +6,7 @@ !README.md !/data !/src +!logging.yaml ## Exclude files in allowed subdirectories **/__pycache__/