Skip to content

Commit

Permalink
Configure logs to stream to console
Browse files Browse the repository at this point in the history
  • Loading branch information
willu47 committed Dec 19, 2024
1 parent 9e4b618 commit 896c494
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/static/js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 0 additions & 7 deletions app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@
<li class="nav-item"><a href="/countries" class="nav-link">Countries</a></li>
</ul>

<script>
$(".nav-pills .nav-link").on("click", function(){
$(".nav").find(".active").removeClass("active");
$(this).addClass("active");
});
</script>

</header>

</div>
Expand Down
10 changes: 9 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ services:
build: .
ports:
- 8000:8000
volumes:
- ri_log:/var/log/research_index.log
environment:
MG_HOST: memgraph
MG_PORT: '7687'
LOG_LEVEL: "DEBUG"
depends_on:
- memgraph
restart: unless-stopped
develop:
watch:
- action: sync
path: .
target: .

memgraph:
image: memgraph/memgraph:latest
Expand All @@ -34,4 +41,5 @@ services:
volumes:
mg_lib:
mg_log:
mg_etc:
mg_etc:
ri_log:
13 changes: 12 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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":
Expand Down

0 comments on commit 896c494

Please sign in to comment.