mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-13 14:44:29 -04:00
fix error log location
This commit is contained in:
parent
26fa63749d
commit
fb8e6cabcb
2 changed files with 11 additions and 8 deletions
|
@ -33,6 +33,7 @@ import django
|
||||||
|
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from datetime import datetime
|
||||||
from typing import Optional, Type, Tuple, Dict, Union, List
|
from typing import Optional, Type, Tuple, Dict, Union, List
|
||||||
from subprocess import run, PIPE, DEVNULL
|
from subprocess import run, PIPE, DEVNULL
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
|
@ -1063,6 +1064,7 @@ def setup_django(out_dir: Path=None, check_db=False, config: ConfigDict=CONFIG,
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import django
|
import django
|
||||||
|
|
||||||
sys.path.append(str(config['PACKAGE_DIR']))
|
sys.path.append(str(config['PACKAGE_DIR']))
|
||||||
os.environ.setdefault('OUTPUT_DIR', str(output_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'
|
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:
|
with connection.cursor() as cursor:
|
||||||
cursor.execute("PRAGMA journal_mode=wal;")
|
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:
|
if check_db:
|
||||||
sql_index_path = Path(output_dir) / SQL_INDEX_FILENAME
|
sql_index_path = Path(output_dir) / SQL_INDEX_FILENAME
|
||||||
assert sql_index_path.exists(), (
|
assert sql_index_path.exists(), (
|
||||||
|
|
|
@ -210,7 +210,7 @@ class NoisyRequestsFilter(logging.Filter):
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
ERROR_LOG = LOGS_DIR / 'errors.log'
|
ERROR_LOG = (LOGS_DIR / 'errors.log') if LOGS_DIR.exists() else '/dev/null'
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
'version': 1,
|
'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")
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue