Best Python code snippet using autotest_python
logging_config.py
Source:logging_config.py
...30 @classmethod31 def get_timestamped_log_name(cls, base_name):32 return '%s.log.%s' % (base_name, time.strftime('%Y-%m-%d-%H.%M.%S'))33 @classmethod34 def get_autotest_root(cls):35 shared_dir = os.path.dirname(__file__)36 return os.path.abspath(os.path.join(shared_dir, '..', '..'))37 @classmethod38 def get_server_log_dir(cls):39 server_log_dir = settings.get_value('SERVER', 'logs_dir', default='')40 if not server_log_dir:41 server_log_dir = os.path.join(cls.get_autotest_root(), 'logs')42 return server_log_dir43 def add_stream_handler(self, stream, level=logging.DEBUG):44 handler = logging.StreamHandler(stream)45 handler.setLevel(level)46 handler.setFormatter(self.console_formatter)47 self.logger.addHandler(handler)48 return handler49 def add_console_handlers(self):50 stdout_handler = self.add_stream_handler(sys.stdout,51 level=self.stdout_level)52 # only pass records *below* STDERR_LEVEL to stdout, to avoid duplication53 stdout_handler.addFilter(AllowBelowSeverity(self.stderr_level))54 self.add_stream_handler(sys.stderr, self.stderr_level)55 def add_file_handler(self, file_path, level=logging.DEBUG, log_dir=None):...
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!!