eive-tmtc/eive_tmtc/pus_tm/defs.py
2023-06-19 17:14:08 +02:00

30 lines
782 B
Python

import logging
from typing import Optional
from tmtccmd.fsfw.tmtc_printer import FsfwTmTcPrinter
class PrintWrapper:
def __init__(self, file_logger: Optional[logging.Logger]):
self.file_logger = file_logger
def dlog(self, string: str):
print(string)
if self.file_logger:
self.file_logger.info(string)
def wlog(self, logger: logging.Logger, string: str):
logger.warning(string)
if self.file_logger:
self.file_logger.warning(string)
def ilog(self, logger: logging.Logger, string: str):
logger.info(string)
if self.file_logger:
self.file_logger.info(string)
def log_to_both(printer: FsfwTmTcPrinter, string: str):
print(string)
printer.file_logger.info(string)