Best Python code snippet using autotest_python
logging_manager.py
Source:logging_manager.py
...246 prefix = tag + ' : '247 self._fmt = base_formatter._fmt.replace('%(message)s',248 prefix + '%(message)s')249 self.datefmt = base_formatter.datefmt250 def _add_tagging_formatter(self, tag):251 for handler in _current_handlers():252 tagging_formatter = self._TaggingFormatter(handler.formatter, tag)253 handler.setFormatter(tagging_formatter)254 def _do_redirect(self, stream=None, filename=None, level=None,255 clear_other_handlers=False):256 """257 @param clear_other_handlers - if true, clear out all other logging258 handlers.259 """260 assert bool(stream) != bool(filename) # xor261 if not self._started:262 raise RuntimeError('You must call start_logging() before this')263 def add_handler(context):264 if clear_other_handlers:265 self._clear_all_handlers()266 if stream:267 handler = self.logging_config_object.add_stream_handler(stream)268 else:269 handler = self.logging_config_object.add_file_handler(filename)270 if level:271 handler.setLevel(level)272 self._add_log_handlers(add_handler)273 def redirect(self, filename):274 """Redirect output to the specified file"""275 self._do_redirect(filename=filename, clear_other_handlers=True)276 def redirect_to_stream(self, stream):277 """Redirect output to the given stream"""278 self._do_redirect(stream=stream, clear_other_handlers=True)279 def tee_redirect(self, filename, level=None):280 """Tee output to the specified file"""281 self._do_redirect(filename=filename, level=level)282 def tee_redirect_to_stream(self, stream):283 """Tee output to the given stream"""284 self._do_redirect(stream=stream)285 def tee_redirect_debug_dir(self, debug_dir, log_name=None, tag=None):286 """287 Tee output to a full new set of debug logs in the given directory.288 """289 def add_handlers(context):290 if tag:291 self._add_tagging_formatter(tag)292 context['tag_added'] = True293 self.logging_config_object.add_debug_file_handlers(294 debug_dir, log_name=log_name)295 self._add_log_handlers(add_handlers)296 def _restore_context(self, context):297 for stream_handler in self._streams:298 stream_handler.on_restore_context(context)299 # restore logging handlers300 old_handlers = context['old_handlers']301 for handler in _current_handlers() - old_handlers:302 handler.close()303 self._clear_all_handlers()304 for handler in old_handlers:305 logger.addHandler(handler)...
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!!