logowanie dla health
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
class IgnoreHealth(logging.Filter):
|
class IgnoreHealth(logging.Filter):
|
||||||
|
def __init__(self, name: str = ""): super().__init__(name)
|
||||||
def filter(self, record: logging.LogRecord) -> bool:
|
def filter(self, record: logging.LogRecord) -> bool:
|
||||||
msg = record.getMessage()
|
return "/health" not in record.getMessage()
|
||||||
return "/health" not in msg
|
|
||||||
|
@@ -4,14 +4,14 @@ services:
|
|||||||
container_name: ip-geo-api
|
container_name: ip-geo-api
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "${PORT:-8080}:8000"
|
- "${PORT:-8080}:${PORT}"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test:
|
test:
|
||||||
[
|
[
|
||||||
"CMD",
|
"CMD",
|
||||||
"python",
|
"python",
|
||||||
"-c",
|
"-c",
|
||||||
"import urllib.request; import sys; req = urllib.request.Request('http://localhost:8000/health'); sys.exit(0) if urllib.request.urlopen(req).read() == b'OK' else sys.exit(1)",
|
"import urllib.request; import sys; req = urllib.request.Request('http://localhost:${PORT}/health'); sys.exit(0) if urllib.request.urlopen(req).read() == b'OK' else sys.exit(1)",
|
||||||
]
|
]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
@@ -24,7 +24,7 @@ services:
|
|||||||
"--host",
|
"--host",
|
||||||
"0.0.0.0",
|
"0.0.0.0",
|
||||||
"--port",
|
"--port",
|
||||||
"8000",
|
"${PORT}",
|
||||||
"--log-config",
|
"--log-config",
|
||||||
"logging.yml",
|
"logging.yml",
|
||||||
]
|
]
|
||||||
|
13
logging.yml
13
logging.yml
@@ -6,21 +6,22 @@ filters:
|
|||||||
"()": app.logging_filter.IgnoreHealth
|
"()": app.logging_filter.IgnoreHealth
|
||||||
|
|
||||||
formatters:
|
formatters:
|
||||||
access:
|
|
||||||
format: '%(levelprefix)s %(client_addr)s - "%(request_line)s" %(status_code)s'
|
|
||||||
use_colors: true
|
|
||||||
default:
|
default:
|
||||||
|
"()": uvicorn.logging.DefaultFormatter
|
||||||
format: "%(levelprefix)s %(message)s"
|
format: "%(levelprefix)s %(message)s"
|
||||||
use_colors: true
|
use_colors: true
|
||||||
|
access:
|
||||||
|
"()": uvicorn.logging.AccessFormatter
|
||||||
|
format: '%(client_addr)s - "%(request_line)s" %(status_code)s'
|
||||||
|
|
||||||
handlers:
|
handlers:
|
||||||
|
default:
|
||||||
|
class: logging.StreamHandler
|
||||||
|
formatter: default
|
||||||
access:
|
access:
|
||||||
class: logging.StreamHandler
|
class: logging.StreamHandler
|
||||||
formatter: access
|
formatter: access
|
||||||
filters: [ignore_health]
|
filters: [ignore_health]
|
||||||
default:
|
|
||||||
class: logging.StreamHandler
|
|
||||||
formatter: default
|
|
||||||
|
|
||||||
loggers:
|
loggers:
|
||||||
uvicorn:
|
uvicorn:
|
||||||
|
Reference in New Issue
Block a user