From 896c494c8e7a7c93cd37a8a20a8ee90848aee6f1 Mon Sep 17 00:00:00 2001 From: Will Usher Date: Thu, 19 Dec 2024 10:10:05 +0100 Subject: [PATCH] Configure logs to stream to console --- app/static/js/map.js | 2 +- app/templates/base.html | 7 ------- compose.yaml | 10 +++++++++- main.py | 13 ++++++++++++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/app/static/js/map.js b/app/static/js/map.js index 944a834..794b379 100644 --- a/app/static/js/map.js +++ b/app/static/js/map.js @@ -41,7 +41,7 @@ function draw_map(country) { d3.json("https://raw.githubusercontent.com/holtzy/D3-graph-gallery/master/DATA/world.geojson").then( function(data){ // Filter data - country = data.features.filter(d => {console.log(d.properties.name); return d.properties.name==country.name}) + country = data.features.filter(d => {return d.properties.name==country.name}) // Initial Map and projection const initial_projection = d3.geoMercator() diff --git a/app/templates/base.html b/app/templates/base.html index 15059d3..b3a179f 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -37,13 +37,6 @@ - - diff --git a/compose.yaml b/compose.yaml index 54ade9f..74fd34c 100644 --- a/compose.yaml +++ b/compose.yaml @@ -3,6 +3,8 @@ services: build: . ports: - 8000:8000 + volumes: + - ri_log:/var/log/research_index.log environment: MG_HOST: memgraph MG_PORT: '7687' @@ -10,6 +12,11 @@ services: depends_on: - memgraph restart: unless-stopped + develop: + watch: + - action: sync + path: . + target: . memgraph: image: memgraph/memgraph:latest @@ -34,4 +41,5 @@ services: volumes: mg_lib: mg_log: - mg_etc: \ No newline at end of file + mg_etc: + ri_log: \ No newline at end of file diff --git a/main.py b/main.py index 5680165..af61bb7 100644 --- a/main.py +++ b/main.py @@ -12,6 +12,17 @@ import logging +# Add console handler to the fastapi logger +console_handler = logging.StreamHandler() +logger.addHandler(console_handler) + +# Use a nice format for the log messages +formatter = logging.Formatter( + "%(asctime)s [%(levelname)s] %(message)s" + ) + +console_handler.setFormatter(formatter) + uvicorn_access_logger = logging.getLogger("uvicorn.access") logger.handlers = uvicorn_access_logger.handlers @@ -117,7 +128,7 @@ def output(request: Request, id: str): entity = output_model.get_output(id) return templates.TemplateResponse( "output.html", - {"request": request, "title": "Output"} | entity ) + {"request": request, "title": "Output"} | entity) if __name__ != "main":