Best Python code snippet using lisa_python
logger.py
Source:logger.py
...119 stdout_logger = get_logger("stdout")120 stderr_logger = get_logger("stderr")121 sys.stdout = cast(TextIO, LogWriter(stdout_logger, logging.INFO))122 sys.stderr = cast(TextIO, LogWriter(stderr_logger, logging.ERROR))123def uninit_logger() -> None:124 # release stdout and stderr. prevent some thread errors may overrides the125 # whole log file.126 sys.stdout = _original_stdout127 sys.stderr = _original_stderr128def enable_console_timestamp() -> None:129 _console_handler.setFormatter(_format)130def add_handler(131 handler: logging.Handler,132 logger: Optional[logging.Logger] = None,133 formatter: Optional[logging.Formatter] = None,134) -> None:135 if is_unittest():136 return None137 if logger is None:...
main.py
Source:main.py
...113 finally:114 log.info(f"completed in {total_timer}")115 if file_handler:116 remove_handler(log_handler=file_handler, logger=log)117 uninit_logger()118 return exit_code119if __name__ == "__main__":120 exit_code = 0121 try:122 exit_code = main()123 except Exception as exception:124 exit_code = -1125 log = get_logger()126 try:127 log.exception(exception)128 except Exception:129 # if there is any exception in log class, they have to be caught and show130 # on console only131 traceback.print_exc()...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!