From patchwork Thu Oct 26 15:33:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alassane Yattara X-Patchwork-Id: 32987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA13FC25B67 for ; Thu, 26 Oct 2023 15:33:17 +0000 (UTC) Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by mx.groups.io with SMTP id smtpd.web10.203563.1698334390314697452 for ; Thu, 26 Oct 2023 08:33:10 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@savoirfairelinux.com header.s=DFC430D2-D198-11EC-948E-34200CB392D2 header.b=Kh1uV3az; spf=pass (domain: savoirfairelinux.com, ip: 208.88.110.44, mailfrom: alassane.yattara@savoirfairelinux.com) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 215069C2929 for ; Thu, 26 Oct 2023 11:33:09 -0400 (EDT) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10032) with ESMTP id gooKO10Aue81; Thu, 26 Oct 2023 11:33:08 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 7C85E9C2BD5; Thu, 26 Oct 2023 11:33:08 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 7C85E9C2BD5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1698334388; bh=SusAWPqJkZsDDDsoUVFtBBrKrnHN8lq2LJWxEI4IbDw=; h=From:To:Date:Message-Id:MIME-Version; b=Kh1uV3az2ZYF57Shbbq9mcLlawf4MMEw2QBo7D7ZMlHlRT54LUw8Kh1kdhzrd9w1H WWOY8t00LgJwX3SxYoifGljVoiWegBcMbFHoEUZy6ktIxtQyZ6wxYdlazrmSuvWA7X //366/e94519zeEuspfLeFIfQ9rcr+IpYll+HKIWw31eJ3zKbyq5kWZARkCQmiurg6 ZGzJCoUgxguIpZNc8Hll9JPAa4pGEjxm1eZJT3Z8OG0SoXB0C6eTCoQUZwmsT1nBIh 3z4hGR4Hx2CmbOZfkOGGTawP03gxVnXOPBW4CboKC31w7No8NWuilFju05yE2tQSPm KM+tzXhus8oKA== X-Virus-Scanned: amavis at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavis, port 10026) with ESMTP id abPx8ydj2O7Z; Thu, 26 Oct 2023 11:33:08 -0400 (EDT) Received: from jedi.. (unknown [196.127.183.75]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id CF30A9C2A91; Thu, 26 Oct 2023 11:33:07 -0400 (EDT) From: Alassane Yattara To: toaster@lists.yoctoproject.org Cc: Alassane Yattara Subject: [PATCH v3] Toaster: Bug-fix logging permission error in docker Date: Thu, 26 Oct 2023 16:33:01 +0100 Message-Id: <20231026153301.872607-1-alassane.yattara@savoirfairelinux.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 26 Oct 2023 15:33:17 -0000 X-Groupsio-URL: https://lists.yoctoproject.org/g/toaster/message/5895 Use BUILDDIR for logs Signed-off-by: Alassane Yattara --- lib/toaster/toastermain/logs.py | 9 +++++---- lib/toaster/toastermain/settings.py | 5 +---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/toaster/toastermain/logs.py b/lib/toaster/toastermain/logs.py index b4910e44..e73d9ff1 100644 --- a/lib/toaster/toastermain/logs.py +++ b/lib/toaster/toastermain/logs.py @@ -1,12 +1,13 @@ #!/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 +BUILDDIR = Path(os.environ.get('BUILDDIR', '/tmp')) def log_api_request(request, response, view, logger_name='api'): @@ -108,7 +109,7 @@ LOGGING_SETTINGS = { 'file_django': { 'level': 'INFO', 'class': 'logging.handlers.TimedRotatingFileHandler', - 'filename': BASE_DIR / 'logs/django.log', + 'filename': BUILDDIR / 'django.log', 'when': 'D', # interval type 'interval': 1, # defaults to 1 'backupCount': 10, # how many files to keep @@ -117,7 +118,7 @@ LOGGING_SETTINGS = { 'file_api': { 'level': 'INFO', 'class': 'logging.handlers.TimedRotatingFileHandler', - 'filename': BASE_DIR / 'logs/api.log', + 'filename': BUILDDIR / 'toaster_api.log', 'when': 'D', 'interval': 1, 'backupCount': 10, @@ -126,7 +127,7 @@ LOGGING_SETTINGS = { 'file_toaster': { 'level': 'INFO', 'class': 'logging.handlers.TimedRotatingFileHandler', - 'filename': BASE_DIR / 'logs/toaster.log', + 'filename': BUILDDIR / 'toaster.log', 'when': 'D', 'interval': 1, 'backupCount': 10, diff --git a/lib/toaster/toastermain/settings.py b/lib/toaster/toastermain/settings.py index b083cf58..bdf7b0b1 100644 --- a/lib/toaster/toastermain/settings.py +++ b/lib/toaster/toastermain/settings.py @@ -315,13 +315,10 @@ for t in os.walk(os.path.dirname(currentdir)): # more details on how to customize your logging configuration. LOGGING = LOGGING_SETTINGS -# Build paths inside the project like this: BASE_DIR / 'subdir'. -BASE_DIR = Path(__file__).resolve(strict=True).parent.parent - # 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 = Path(os.environ.get('BUILDDIR', '/tmp')) 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']