Skip to content

logging

zeus.util.logging

Utilities for logging.

FileAndConsole

Like tee, but for Python prints.

Source code in zeus/util/logging.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
class FileAndConsole:
    """Like tee, but for Python prints."""

    def __init__(self, filepath: Path) -> None:
        """Initialize the object."""
        self.file = open(filepath, "w")
        self.stdout = sys.stdout

    def write(self, message):
        """Write message."""
        self.file.write(message)
        self.stdout.write(message)
        self.file.flush()
        self.stdout.flush()

    def flush(self):
        """Flush both log file and stdout."""
        self.file.flush()
        self.stdout.flush()

__init__

__init__(filepath)
Source code in zeus/util/logging.py
24
25
26
27
def __init__(self, filepath: Path) -> None:
    """Initialize the object."""
    self.file = open(filepath, "w")
    self.stdout = sys.stdout

write

write(message)

Write message.

Source code in zeus/util/logging.py
29
30
31
32
33
34
def write(self, message):
    """Write message."""
    self.file.write(message)
    self.stdout.write(message)
    self.file.flush()
    self.stdout.flush()

flush

flush()

Flush both log file and stdout.

Source code in zeus/util/logging.py
36
37
38
39
def flush(self):
    """Flush both log file and stdout."""
    self.file.flush()
    self.stdout.flush()