log to file

This commit is contained in:
Kiara Grouwstra 2025-04-12 09:56:00 +02:00
parent f87275e384
commit 1a8d940a90
Signed by: kiara
SSH key fingerprint: SHA256:COspvLoLJ5WC5rFb9ZDe5urVCkK4LJZOsjfF4duRJFU
4 changed files with 12 additions and 1 deletions

1
.gitignore vendored
View file

@ -12,3 +12,4 @@ result*
*screenshot.png
output
todo
log/

View file

@ -31,6 +31,7 @@ in
DATABASE_URL = "sqlite:///${toString ./src}/db.sqlite3";
# locally: use a fixed relative reference, so we can use our newest files without copying to the store
REPO_DIR = toString ../.;
LOGGING_DIR = "../log";
};
shellHook = ''
ln -sf ${sources.htmx}/dist/htmx.js src/panel/static/htmx.min.js

View file

@ -30,6 +30,7 @@ let
(builtins.toFile "extra-settings.py" cfg.extra-settings)
];
REPO_DIR = import ../../launch/tf-env.nix { inherit lib pkgs; };
LOGGING_DIR = "/var/log/${name}";
};
python-environment = pkgs.python3.withPackages (

View file

@ -175,6 +175,9 @@ COMPRESS_PRECOMPILERS = [
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
logging_dir = env["LOGGING_DIR"]
os.makedirs(logging_dir, mode=0o700, exist_ok=True)
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
@ -209,10 +212,15 @@ LOGGING = {
"filters": ["require_debug_false"],
"class": "django.utils.log.AdminEmailHandler",
},
"file": {
"level": "INFO",
"class": "logging.FileHandler",
"filename": f"{logging_dir}/info.log",
},
},
"loggers": {
"django": {
"handlers": ["console", "mail_admins"],
"handlers": ["console", "mail_admins", "file"],
"level": "INFO",
},
"django.server": {