1
0
Fork 0
mirror of synced 2024-06-26 10:00:19 +12:00

fix error log location

This commit is contained in:
Nick Sweeting 2021-02-16 04:15:09 -05:00
parent 26fa63749d
commit fb8e6cabcb
2 changed files with 11 additions and 8 deletions

View file

@ -33,6 +33,7 @@ import django
from hashlib import md5
from pathlib import Path
from datetime import datetime
from typing import Optional, Type, Tuple, Dict, Union, List
from subprocess import run, PIPE, DEVNULL
from configparser import ConfigParser
@ -1063,6 +1064,7 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG,
try:
import django
sys.path.append(str(config['PACKAGE_DIR']))
os.environ.setdefault('OUTPUT_DIR', str(output_dir))
assert (config['PACKAGE_DIR'] / 'core' / 'settings.py').exists(), 'settings.py was not found at archivebox/core/settings.py'
@ -1082,6 +1084,14 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG,
with connection.cursor() as cursor:
cursor.execute("PRAGMA journal_mode=wal;")
from django.conf import settings
# log startup message to the error log
with open(settings.ERROR_LOG, "a+") as f:
command = ' '.join(sys.argv)
ts = datetime.now().strftime('%Y-%m-%d__%H:%M:%S')
f.write(f"\n> {command}; ts={ts} version={VERSION} docker={IN_DOCKER} is_tty={IS_TTY}\n")
if check_db:
sql_index_path = Path(output_dir) / SQL_INDEX_FILENAME
assert sql_index_path.exists(), (

View file

@ -210,7 +210,7 @@ class NoisyRequestsFilter(logging.Filter):
return 1
ERROR_LOG = LOGS_DIR / 'errors.log'
ERROR_LOG = (LOGS_DIR / 'errors.log') if LOGS_DIR.exists() else '/dev/null'
LOGGING = {
'version': 1,
@ -245,10 +245,3 @@ LOGGING = {
}
},
}
# log startup message to the error log
with open(ERROR_LOG, "a+") as f:
command = ' '.join(sys.argv)
ts = datetime.now().strftime('%Y-%m-%d__%H:%M:%S')
f.write(f"\n> {command}; ts={ts} version={VERSION} docker={IN_DOCKER} is_tty={IS_TTY}\n")