File: logs.py

package info (click to toggle)
debugpy 1.6.6%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,264 kB
  • sloc: python: 13,833; sh: 244; makefile: 25
file content (31 lines) | stat: -rw-r--r-- 977 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See LICENSE in the project root
# for license information.

import io
import os
import pytest_timeout
import sys

from debugpy.common import json, log


def dump():
    if log.log_dir is None:
        return
    log.info("Dumping logs from {0}", json.repr(log.log_dir))

    for dirpath, dirnames, filenames in os.walk(log.log_dir):
        for name in sorted(filenames):
            if not name.startswith("debugpy") and not name.startswith("pydevd"):
                continue
            try:
                path = os.path.join(dirpath, name)
                with io.open(path, encoding="utf-8", errors="backslashreplace") as f:
                    s = f.read()
            except Exception:
                pass
            else:
                path = os.path.relpath(path, log.log_dir)
                pytest_timeout.write_title(path)
                print(s, file=sys.stderr)