diff options
| -rwxr-xr-x | bitbake/bin/toaster | 12 | ||||
| -rw-r--r-- | bitbake/lib/toaster/toastermain/logs.py | 10 | ||||
| -rw-r--r-- | bitbake/lib/toaster/toastermain/settings.py | 4 |
3 files changed, 17 insertions, 9 deletions
diff --git a/bitbake/bin/toaster b/bitbake/bin/toaster index 558a819570..f002c8c159 100755 --- a/bitbake/bin/toaster +++ b/bitbake/bin/toaster | |||
| @@ -84,7 +84,7 @@ webserverStartAll() | |||
| 84 | echo "Starting webserver..." | 84 | echo "Starting webserver..." |
| 85 | 85 | ||
| 86 | $MANAGE runserver --noreload "$ADDR_PORT" \ | 86 | $MANAGE runserver --noreload "$ADDR_PORT" \ |
| 87 | </dev/null >>${BUILDDIR}/toaster_web.log 2>&1 \ | 87 | </dev/null >>${TOASTER_LOGS_DIR}/web.log 2>&1 \ |
| 88 | & echo $! >${BUILDDIR}/.toastermain.pid | 88 | & echo $! >${BUILDDIR}/.toastermain.pid |
| 89 | 89 | ||
| 90 | sleep 1 | 90 | sleep 1 |
| @@ -181,6 +181,14 @@ WEBSERVER=1 | |||
| 181 | export TOASTER_BUILDSERVER=1 | 181 | export TOASTER_BUILDSERVER=1 |
| 182 | ADDR_PORT="localhost:8000" | 182 | ADDR_PORT="localhost:8000" |
| 183 | TOASTERDIR=`dirname $BUILDDIR` | 183 | TOASTERDIR=`dirname $BUILDDIR` |
| 184 | # ${BUILDDIR}/toaster_logs/ became the default location for toaster logs | ||
| 185 | # This is needed for implemented django-log-viewer: https://pypi.org/project/django-log-viewer/ | ||
| 186 | # If the directory does not exist, create it. | ||
| 187 | TOASTER_LOGS_DIR="${BUILDDIR}/toaster_logs/" | ||
| 188 | if [ ! -d $TOASTER_LOGS_DIR ] | ||
| 189 | then | ||
| 190 | mkdir $TOASTER_LOGS_DIR | ||
| 191 | fi | ||
| 184 | unset CMD | 192 | unset CMD |
| 185 | for param in $*; do | 193 | for param in $*; do |
| 186 | case $param in | 194 | case $param in |
| @@ -299,7 +307,7 @@ case $CMD in | |||
| 299 | export BITBAKE_UI='toasterui' | 307 | export BITBAKE_UI='toasterui' |
| 300 | if [ $TOASTER_BUILDSERVER -eq 1 ] ; then | 308 | if [ $TOASTER_BUILDSERVER -eq 1 ] ; then |
| 301 | $MANAGE runbuilds \ | 309 | $MANAGE runbuilds \ |
| 302 | </dev/null >>${BUILDDIR}/toaster_runbuilds.log 2>&1 \ | 310 | </dev/null >>${TOASTER_LOGS_DIR}/toaster_runbuilds.log 2>&1 \ |
| 303 | & echo $! >${BUILDDIR}/.runbuilds.pid | 311 | & echo $! >${BUILDDIR}/.runbuilds.pid |
| 304 | else | 312 | else |
| 305 | echo "Toaster build server not started." | 313 | echo "Toaster build server not started." |
diff --git a/bitbake/lib/toaster/toastermain/logs.py b/bitbake/lib/toaster/toastermain/logs.py index b4910e4432..62d871963a 100644 --- a/bitbake/lib/toaster/toastermain/logs.py +++ b/bitbake/lib/toaster/toastermain/logs.py | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python3 |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | 3 | ||
| 4 | import os | ||
| 4 | import logging | 5 | import logging |
| 5 | import json | 6 | import json |
| 6 | from pathlib import Path | 7 | from pathlib import Path |
| 7 | from django.http import HttpRequest | 8 | from django.http import HttpRequest |
| 8 | 9 | ||
| 9 | BASE_DIR = Path(__file__).resolve(strict=True).parent.parent | 10 | BUILDDIR = Path(os.environ.get('BUILDDIR', '/tmp')) |
| 10 | |||
| 11 | 11 | ||
| 12 | def log_api_request(request, response, view, logger_name='api'): | 12 | def log_api_request(request, response, view, logger_name='api'): |
| 13 | """Helper function for LogAPIMixin""" | 13 | """Helper function for LogAPIMixin""" |
| @@ -108,7 +108,7 @@ LOGGING_SETTINGS = { | |||
| 108 | 'file_django': { | 108 | 'file_django': { |
| 109 | 'level': 'INFO', | 109 | 'level': 'INFO', |
| 110 | 'class': 'logging.handlers.TimedRotatingFileHandler', | 110 | 'class': 'logging.handlers.TimedRotatingFileHandler', |
| 111 | 'filename': BASE_DIR / 'logs/django.log', | 111 | 'filename': BUILDDIR / 'toaster_logs/django.log', |
| 112 | 'when': 'D', # interval type | 112 | 'when': 'D', # interval type |
| 113 | 'interval': 1, # defaults to 1 | 113 | 'interval': 1, # defaults to 1 |
| 114 | 'backupCount': 10, # how many files to keep | 114 | 'backupCount': 10, # how many files to keep |
| @@ -117,7 +117,7 @@ LOGGING_SETTINGS = { | |||
| 117 | 'file_api': { | 117 | 'file_api': { |
| 118 | 'level': 'INFO', | 118 | 'level': 'INFO', |
| 119 | 'class': 'logging.handlers.TimedRotatingFileHandler', | 119 | 'class': 'logging.handlers.TimedRotatingFileHandler', |
| 120 | 'filename': BASE_DIR / 'logs/api.log', | 120 | 'filename': BUILDDIR / 'toaster_logs/api.log', |
| 121 | 'when': 'D', | 121 | 'when': 'D', |
| 122 | 'interval': 1, | 122 | 'interval': 1, |
| 123 | 'backupCount': 10, | 123 | 'backupCount': 10, |
| @@ -126,7 +126,7 @@ LOGGING_SETTINGS = { | |||
| 126 | 'file_toaster': { | 126 | 'file_toaster': { |
| 127 | 'level': 'INFO', | 127 | 'level': 'INFO', |
| 128 | 'class': 'logging.handlers.TimedRotatingFileHandler', | 128 | 'class': 'logging.handlers.TimedRotatingFileHandler', |
| 129 | 'filename': BASE_DIR / 'logs/toaster.log', | 129 | 'filename': BUILDDIR / 'toaster_logs/web.log', |
| 130 | 'when': 'D', | 130 | 'when': 'D', |
| 131 | 'interval': 1, | 131 | 'interval': 1, |
| 132 | 'backupCount': 10, | 132 | 'backupCount': 10, |
diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py index b083cf5885..5de881c4bb 100644 --- a/bitbake/lib/toaster/toastermain/settings.py +++ b/bitbake/lib/toaster/toastermain/settings.py | |||
| @@ -316,12 +316,12 @@ for t in os.walk(os.path.dirname(currentdir)): | |||
| 316 | LOGGING = LOGGING_SETTINGS | 316 | LOGGING = LOGGING_SETTINGS |
| 317 | 317 | ||
| 318 | # Build paths inside the project like this: BASE_DIR / 'subdir'. | 318 | # Build paths inside the project like this: BASE_DIR / 'subdir'. |
| 319 | BASE_DIR = Path(__file__).resolve(strict=True).parent.parent | 319 | BUILDDIR = os.environ.get("BUILDDIR", "/tmp") |
| 320 | 320 | ||
| 321 | # LOG VIEWER | 321 | # LOG VIEWER |
| 322 | # https://pypi.org/project/django-log-viewer/ | 322 | # https://pypi.org/project/django-log-viewer/ |
| 323 | LOG_VIEWER_FILES_PATTERN = '*.log*' | 323 | LOG_VIEWER_FILES_PATTERN = '*.log*' |
| 324 | LOG_VIEWER_FILES_DIR = os.path.join(BASE_DIR, 'logs') | 324 | LOG_VIEWER_FILES_DIR = os.path.join(BUILDDIR, "toaster_logs/") |
| 325 | LOG_VIEWER_PAGE_LENGTH = 25 # total log lines per-page | 325 | LOG_VIEWER_PAGE_LENGTH = 25 # total log lines per-page |
| 326 | LOG_VIEWER_MAX_READ_LINES = 100000 # total log lines will be read | 326 | LOG_VIEWER_MAX_READ_LINES = 100000 # total log lines will be read |
| 327 | LOG_VIEWER_PATTERNS = ['INFO', 'DEBUG', 'WARNING', 'ERROR', 'CRITICAL'] | 327 | LOG_VIEWER_PATTERNS = ['INFO', 'DEBUG', 'WARNING', 'ERROR', 'CRITICAL'] |
