($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: Tim Orling <ticotimo@gmail.com>
To: alassane.yattara@savoirfairelinux.com
Cc: bitbake-devel@lists.openembedded.org,
	toaster@lists.yoctoproject.org,
	 Tim Orling <tim.orling@konsulko.com>
Subject: Re: [Toaster] [PATCH] toaster: write logs to BUILDDIR
Date: Thu, 26 Oct 2023 10:54:13 -0700	[thread overview]
Message-ID: <CANx9H-B_VfuVxHqK7F3M7+zy1OH0Thv41ZAZHCXUn_Nttpof9g@mail.gmail.com> (raw)
In-Reply-To: <1791B341DCBB88FE.20272@lists.yoctoproject.org>

[-- Attachment #1: Type: text/plain, Size: 5021 bytes --]

Allassane,

At least when running in the toaster-container, I'm seeing no logs, but
links like "conf/toaster_api.log", but that file doesn't exist and is not
downloadable.

I tried a couple other changes on:
https://git.yoctoproject.org/poky-contrib/log/?h=timo/toaster-logging-v3
(one of which was present in your series earlier today).

But I don't have experience with the log_viewer plugin and I'm not sure
what is happening to cause the "conf/" to be prepended to the log links in
the admin interface.

On Thu, Oct 26, 2023 at 8:53 AM Tim Orling via lists.yoctoproject.org
<ticotimo=gmail.com@lists.yoctoproject.org> wrote:

> Fixes "2efb14648 toaster: Monitoring - implement Django logging system"
> when
> running in a container.
>
> When running in a container, the previous approach of using BASE_DIR
> is not a writable path. Also, we really do not want to be writing logs into
> the source tree, as the BASE_DIR was resolving to bitbake/lib/toaster/logs
>
> Since Toaster is only ever running in an environment where oe-init-buildenv
> or similar has been sourced, we should instead write the logs to BUILDDIR.
> This is where the existing toaster_ui.log was already being written.
>
> Drop the /logs/ directory, as it has not been created which also breaks
> in a container environment. Instead, prepend the api.log, etc. with
> "toaster_"
> and write them alongside the existing toaster_ui.log
>
> Signed-off-by: Tim Orling <tim.orling@konsulko.com>
> ---
>  lib/toaster/toastermain/logs.py     | 9 +++++----
>  lib/toaster/toastermain/settings.py | 7 ++++---
>  2 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/lib/toaster/toastermain/logs.py
> b/lib/toaster/toastermain/logs.py
> index b4910e443..5a296bc3f 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'))
>
>
>  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 / 'toaster_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 b083cf588..c65f4b630 100644
> --- a/lib/toaster/toastermain/settings.py
> +++ b/lib/toaster/toastermain/settings.py
> @@ -315,13 +315,14 @@ 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
> +# Rather than using BASE_DIR inside the source tree, we use
> +# BUILDDIR which is exported by the bitbake environment
> +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 = BUILDDIR
>  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']
> --
> 2.34.1
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#5896):
> https://lists.yoctoproject.org/g/toaster/message/5896
> Mute This Topic: https://lists.yoctoproject.org/mt/102202795/924729
> Group Owner: toaster+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/toaster/unsub [
> ticotimo@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>

[-- Attachment #2: Type: text/html, Size: 6943 bytes --]

       reply	other threads:[~2023-10-26 17:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1791B341DCBB88FE.20272@lists.yoctoproject.org>
2023-10-26 17:54 ` Tim Orling [this message]
2023-10-26 18:42   ` [Toaster] [PATCH] toaster: write logs to BUILDDIR Alassane Yattara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANx9H-B_VfuVxHqK7F3M7+zy1OH0Thv41ZAZHCXUn_Nttpof9g@mail.gmail.com \
    --to=ticotimo@gmail.com \
    --cc=alassane.yattara@savoirfairelinux.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=tim.orling@konsulko.com \
    --cc=toaster@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).