########################################################################### # # Copyright (c) 2021-2024 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file test_logging.py # # @author (last) Peter Lucia # @date (last) 21-May-2021 # @author (original) Peter Lucia # @date (original) 29-Apr-2021 # ############################################################################ import sys import subprocess sys.path.append("../../") from dialin.dg.dialysate_generator import DG from dialin.hd.hemodialysis_device import HD from dialin.utils import create_logger import time import logging from logging import Logger def test_logging(): """ Prints the DG version. @return: None """ if False: # hd = DG(log_level="INFO") dg = DG() if dg.cmd_log_in_to_dg(): dg.cmd_ui_request_dg_version() time.sleep(0.5) print(dg.dg_version) if True: # hd = HD(log_level="CAN_ONLY") hd = HD(log_level="CAN_ONLY") if hd.cmd_log_in_to_hd(): hd.ui.cmd_ui_request_hd_version() class HDDevice(HD): def __init__(self): super().__init__() self.vvlogger = create_logger("vvlogger.log", "NOT_SET", enable_metadata=False, clear_before_write=True) self.vvlogger.debug("VVLOGGER: INITIALIZE") self.logger.debug("TESTING123") self.vvlogger.getEffectiveLevel() def test_create_logger(): subprocess.call("rm *.log", shell=True) hd = HDDevice() print(hd.vvlogger.getEffectiveLevel()) hd.vvlogger.debug("VVLOGGER: TEST 1 (BEFORE DIALIN logger.debug() calls)") hd.test_debug() hd.vvlogger.debug("VVLOGGER: TEST 2 (AFTER DIALIN logger.debug() calls)") # observe that no dialin logger.debug() messages appear in vvlogger.log # and no dialin logger.debug() messages appear in the pycharm console (same behavior when running from terminal). if __name__ == '__main__': test_create_logger()