Skip to content

whos_there.senders.debug

[docs] module whos_there.senders.debug

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from typing import Any

from whos_there.senders.base import Sender
from whos_there.utils.logging import get_logger

logger = get_logger(__name__)


class DebugSender(Sender):
    def __init__(self, print: bool = False) -> None:
        """Initialize the Debug sender.

        Uses the Python logger. Performs logging on rank zero only in a distributed mode.

        Args:
            print: If enabled, outputs using the print command in addition. Defaults to False.. Defaults to False.
        """
        super().__init__()
        self.print = print

    def send(self, text: str) -> Any:
        logger.debug(text)
        if self.print:
            print(text)