From d486f8c1622e59cdf5307bd45d07ecfe8d90ebc1 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Sat, 27 Mar 2021 02:17:12 -0400 Subject: [PATCH] use tempfile when logs dir is not available --- archivebox/core/settings.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/archivebox/core/settings.py b/archivebox/core/settings.py index 5049cdd7..6a795702 100644 --- a/archivebox/core/settings.py +++ b/archivebox/core/settings.py @@ -4,6 +4,7 @@ import os import sys import re import logging +import tempfile from pathlib import Path from django.utils.crypto import get_random_string @@ -248,7 +249,12 @@ class NoisyRequestsFilter(logging.Filter): return 1 -ERROR_LOG = (LOGS_DIR / 'errors.log') if LOGS_DIR.exists() else '/dev/null' +if LOGS_DIR.exists(): + ERROR_LOG = (LOGS_DIR / 'errors.log') +else: + # meh too many edge cases here around creating log dir w/ correct permissions + # cant be bothered, just trash the log and let them figure it out via stdout/stderr + ERROR_LOG = tempfile.NamedTemporaryFile().name LOGGING = { 'version': 1,