Reapply "log to file"

This reverts commit b0942bd174.
This commit is contained in:
Kiara Grouwstra 2025-04-12 14:10:55 +02:00
parent d4860c8aed
commit 1983508fb1
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 *screenshot.png
output output
todo todo
log/

View file

@ -31,6 +31,7 @@ in
DATABASE_URL = "sqlite:///${toString ./src}/db.sqlite3"; 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 # locally: use a fixed relative reference, so we can use our newest files without copying to the store
REPO_DIR = toString ../.; REPO_DIR = toString ../.;
LOGGING_DIR = "../log";
}; };
shellHook = '' shellHook = ''
ln -sf ${sources.htmx}/dist/htmx.js src/panel/static/htmx.min.js 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) (builtins.toFile "extra-settings.py" cfg.extra-settings)
]; ];
REPO_DIR = import ../../launch/tf-env.nix { inherit lib pkgs; }; REPO_DIR = import ../../launch/tf-env.nix { inherit lib pkgs; };
LOGGING_DIR = "/var/log/${name}";
SSH_PRIVATE_KEY_FILE = config.age.secrets.panel-ssh-key.path; SSH_PRIVATE_KEY_FILE = config.age.secrets.panel-ssh-key.path;
}; };

View file

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