mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
add logging.config.fileConfig
This resolves logging issues with alembic on aurweb.initdb in addition to adding more logging utilities for aurweb and tests in general. Developers should fetch a logger for their specific module via `logging.getLogger(__name__)`. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
865c414504
commit
55c0637b98
5 changed files with 76 additions and 0 deletions
|
@ -9,6 +9,7 @@ from starlette.middleware.authentication import AuthenticationMiddleware
|
|||
from starlette.middleware.sessions import SessionMiddleware
|
||||
|
||||
import aurweb.config
|
||||
import aurweb.logging
|
||||
|
||||
from aurweb.auth import BasicAuthBackend
|
||||
from aurweb.db import get_engine
|
||||
|
|
|
@ -4,6 +4,7 @@ import alembic.command
|
|||
import alembic.config
|
||||
|
||||
import aurweb.db
|
||||
import aurweb.logging
|
||||
import aurweb.schema
|
||||
|
||||
|
||||
|
|
11
aurweb/logging.py
Normal file
11
aurweb/logging.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
import logging
|
||||
import logging.config
|
||||
import os
|
||||
|
||||
import aurweb.config
|
||||
|
||||
aurwebdir = aurweb.config.get("options", "aurwebdir")
|
||||
config_path = os.path.join(aurwebdir, "logging.conf")
|
||||
|
||||
logging.config.fileConfig(config_path, disable_existing_loggers=False)
|
||||
logger = logging.getLogger(__name__)
|
62
logging.conf
Normal file
62
logging.conf
Normal file
|
@ -0,0 +1,62 @@
|
|||
[loggers]
|
||||
keys=root,aurweb,test,uvicorn,hypercorn,alembic
|
||||
|
||||
[handlers]
|
||||
keys=simpleHandler,detailedHandler
|
||||
|
||||
[formatters]
|
||||
keys=simpleFormatter,detailedFormatter
|
||||
|
||||
[logger_root]
|
||||
level=INFO
|
||||
handlers=simpleHandler
|
||||
|
||||
[logger_aurweb]
|
||||
level=DEBUG
|
||||
handlers=detailedHandler
|
||||
qualname=aurweb
|
||||
propagate=0
|
||||
|
||||
[logger_test]
|
||||
level=DEBUG
|
||||
handlers=detailedHandler
|
||||
qualname=test
|
||||
propagate=0
|
||||
|
||||
[logger_uvicorn]
|
||||
level=DEBUG
|
||||
handlers=simpleHandler
|
||||
qualname=uvicorn
|
||||
propagate=0
|
||||
|
||||
[logger_hypercorn]
|
||||
level=DEBUG
|
||||
handlers=simpleHandler
|
||||
qualname=hypercorn
|
||||
propagate=0
|
||||
|
||||
[logger_alembic]
|
||||
level=INFO
|
||||
handlers=simpleHandler
|
||||
qualname=alembic
|
||||
propagate=0
|
||||
|
||||
[handler_simpleHandler]
|
||||
class=StreamHandler
|
||||
level=DEBUG
|
||||
formatter=simpleFormatter
|
||||
args=(sys.stdout,)
|
||||
|
||||
[handler_detailedHandler]
|
||||
class=StreamHandler
|
||||
level=DEBUG
|
||||
formatter=detailedFormatter
|
||||
args=(sys.stdout,)
|
||||
|
||||
[formatter_simpleFormatter]
|
||||
format=%(asctime)s %(levelname)-5s | %(name)s: %(message)s
|
||||
datefmt=%H:%M:%S
|
||||
|
||||
[formatter_detailedFormatter]
|
||||
format=%(asctime)s %(levelname)-5s | %(name)s.%(funcName)s() @ L%(lineno)d: %(message)s
|
||||
datefmt=%H:%M:%S
|
|
@ -30,6 +30,7 @@ backend = sqlite
|
|||
name = aur.db
|
||||
|
||||
[options]
|
||||
aurwebdir = $TOPLEVEL
|
||||
aur_location = https://aur.archlinux.org
|
||||
aur_request_ml = aur-requests@lists.archlinux.org
|
||||
enable-maintenance = 0
|
||||
|
|
Loading…
Add table
Reference in a new issue