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__/ 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 96dd870..86704b1 100644 --- a/backend/src/atlas_assistant/api.py +++ b/backend/src/atlas_assistant/api.py @@ -194,6 +194,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", @@ -246,8 +247,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 c597a2b..c877002 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 760f386..eff2265 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 +}