mirror of
https://github.com/jointakahe/takahe.git
synced 2025-01-21 20:08:06 +00:00
logging config for stator the same was as it works for gunicorn
This commit is contained in:
parent
837320f461
commit
bf2f5378a5
1 changed files with 10 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
import logging
|
import logging
|
||||||
|
import logging.config
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
|
@ -49,6 +50,12 @@ class Command(BaseCommand):
|
||||||
action="append",
|
action="append",
|
||||||
help="Model labels that should not be processed",
|
help="Model labels that should not be processed",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--log-config",
|
||||||
|
type=str,
|
||||||
|
default=None,
|
||||||
|
help="Configuration file for logging",
|
||||||
|
)
|
||||||
parser.add_argument("model_labels", nargs="*", type=str)
|
parser.add_argument("model_labels", nargs="*", type=str)
|
||||||
|
|
||||||
def handle(
|
def handle(
|
||||||
|
@ -59,6 +66,7 @@ class Command(BaseCommand):
|
||||||
schedule_interval: int,
|
schedule_interval: int,
|
||||||
run_for: int,
|
run_for: int,
|
||||||
exclude: list[str],
|
exclude: list[str],
|
||||||
|
log_config: str,
|
||||||
*args,
|
*args,
|
||||||
**options
|
**options
|
||||||
):
|
):
|
||||||
|
@ -68,8 +76,9 @@ class Command(BaseCommand):
|
||||||
format="[%(asctime)s] %(levelname)8s - %(message)s",
|
format="[%(asctime)s] %(levelname)8s - %(message)s",
|
||||||
datefmt="%Y-%m-%d %H:%M:%S",
|
datefmt="%Y-%m-%d %H:%M:%S",
|
||||||
level=logging.INFO,
|
level=logging.INFO,
|
||||||
force=True,
|
|
||||||
)
|
)
|
||||||
|
if log_config:
|
||||||
|
logging.config.fileConfig(log_config)
|
||||||
# Resolve the models list into names
|
# Resolve the models list into names
|
||||||
models = cast(
|
models = cast(
|
||||||
list[type[StatorModel]],
|
list[type[StatorModel]],
|
||||||
|
|
Loading…
Reference in a new issue