Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Sub folder is not considered #35

Closed
andychoi opened this issue Jan 27, 2023 · 1 comment
Closed

Sub folder is not considered #35

andychoi opened this issue Jan 27, 2023 · 1 comment

Comments

@andychoi
Copy link
Contributor

andychoi commented Jan 27, 2023

Details

  • OS (Operating System) version:
  • Browser and browser version:
  • Django version:
  • Log viewer version:

Steps to reproduce

  1. no special configuration
  2. view logs

Below looping logic is overwriting result["logs"] which is a bug. It ends up showing last sub-folder only.

def get_log_files(directory, max_items_per_page, current_page):
    result = {}
    for root, _, files in os.walk(directory):
        all_files = list(filter(lambda x: x.find("~") == -1, files))

        all_log_files = []
        all_log_files.extend(
            list(filter(lambda x: x in settings.LOG_VIEWER_FILES, all_files))
        )
        all_log_files.extend(
            [x for x in all_files if fnmatch(x, settings.LOG_VIEWER_FILES_PATTERN)]
        )
        log_dir = os.path.relpath(root, directory)
        if log_dir == ".":
            log_dir = ""

        result["logs"] = {log_dir: list(set(all_log_files))}
        result["next_page_files"] = current_page + 1
        result["last_files"] = (
            all_log_files.__len__() <= current_page * max_items_per_page
        )

    return result
@agusmakmun
Copy link
Owner

Thank you for resolving this issue, it's now available in this version:
https://github.com/agusmakmun/django-log-viewer/releases/tag/v1.1.7

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants