diff mbox series

[1/3] Bug-fix logging permission error in docker

Message ID 20231026140615.792919-1-alassane.yattara@savoirfairelinux.com
State New
Headers show
Series [1/3] Bug-fix logging permission error in docker | expand

Commit Message

Alassane Yattara Oct. 26, 2023, 2:06 p.m. UTC
From: Tim Orling <tim.orling@konsulko.com>

toastermain: use BUILDDIR for logs

Developer: Tim Orling
Reviewer: Alassane Yattara

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Signed-off-by: Alassane Yattara <alassane.yattara@savoirfairelinux.com>
---
 bitbake/lib/toaster/toastermain/logs.py     | 10 ++++++----
 bitbake/lib/toaster/toastermain/settings.py |  5 +++--
 2 files changed, 9 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/bitbake/lib/toaster/toastermain/logs.py b/bitbake/lib/toaster/toastermain/logs.py
index b4910e4432..db5d459f9b 100644
--- a/bitbake/lib/toaster/toastermain/logs.py
+++ b/bitbake/lib/toaster/toastermain/logs.py
@@ -1,12 +1,14 @@ 
 #!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 
+import os
 import logging
 import json
 from pathlib import Path
 from django.http import HttpRequest
 
-BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
+#BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
+BUILDDIR = os.environ.get("BUILDDIR")
 
 
 def log_api_request(request, response, view, logger_name='api'):
@@ -108,7 +110,7 @@  LOGGING_SETTINGS = {
         'file_django': {
             'level': 'INFO',
             'class': 'logging.handlers.TimedRotatingFileHandler',
-            'filename': BASE_DIR / 'logs/django.log',
+            'filename': BUILDDIR / 'logs/django.log',
             'when': 'D',  # interval type
             'interval': 1,  # defaults to 1
             'backupCount': 10,  # how many files to keep
@@ -117,7 +119,7 @@  LOGGING_SETTINGS = {
         'file_api': {
             'level': 'INFO',
             'class': 'logging.handlers.TimedRotatingFileHandler',
-            'filename': BASE_DIR / 'logs/api.log',
+            'filename': BUILDDIR / 'logs/api.log',
             'when': 'D',
             'interval': 1,
             'backupCount': 10,
@@ -126,7 +128,7 @@  LOGGING_SETTINGS = {
         'file_toaster': {
             'level': 'INFO',
             'class': 'logging.handlers.TimedRotatingFileHandler',
-            'filename': BASE_DIR / 'logs/toaster.log',
+            'filename': BUILDDIR / 'logs/toaster.log',
             'when': 'D',
             'interval': 1,
             'backupCount': 10,
diff --git a/bitbake/lib/toaster/toastermain/settings.py b/bitbake/lib/toaster/toastermain/settings.py
index b083cf5885..50b873cb49 100644
--- a/bitbake/lib/toaster/toastermain/settings.py
+++ b/bitbake/lib/toaster/toastermain/settings.py
@@ -316,12 +316,13 @@  for t in os.walk(os.path.dirname(currentdir)):
 LOGGING = LOGGING_SETTINGS
 
 # Build paths inside the project like this: BASE_DIR / 'subdir'.
-BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
+#BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
+BUILDDIR = os.environ.get("BUILDDIR")
 
 # LOG VIEWER
 # https://pypi.org/project/django-log-viewer/
 LOG_VIEWER_FILES_PATTERN = '*.log*'
-LOG_VIEWER_FILES_DIR = os.path.join(BASE_DIR, 'logs')
+LOG_VIEWER_FILES_DIR = os.path.join(BUILDDIR, 'logs')
 LOG_VIEWER_PAGE_LENGTH = 25      # total log lines per-page
 LOG_VIEWER_MAX_READ_LINES = 100000  # total log lines will be read
 LOG_VIEWER_PATTERNS = ['INFO', 'DEBUG', 'WARNING', 'ERROR', 'CRITICAL']