How to use add_console_handlers method in autotest

Best Python code snippet using autotest_python

logging_config.py

Source:logging_config.py Github

copy

Full Screen

...32 if self.set_fmt:33 handler.setFormatter(self.console_formatter)34 self.logger.addHandler(handler)35 return handler36 def add_console_handlers(self):37 stdout_handler = self.add_stream_handler(sys.stdout,38 level=self.stdout_level)39 # only pass records *below* STDERR_LEVEL to stdout, to avoid40 # duplication41 stdout_handler.addFilter(AllowBelowSeverity(self.stderr_level))42 self.add_stream_handler(sys.stderr, self.stderr_level)43 def add_file_handler(self, file_path, level=logging.DEBUG, log_dir=None):44 if log_dir:45 file_path = os.path.join(log_dir, file_path)46 handler = logging.FileHandler(file_path)47 handler.setLevel(level)48 if self.set_fmt:49 handler.setFormatter(self.file_formatter)50 self.logger.addHandler(handler)51 return handler52 def _add_file_handlers_for_all_levels(self, log_dir, log_name):53 for level in (logging.DEBUG, logging.INFO, logging.WARNING,54 logging.ERROR):55 file_name = '%s.%s' % (log_name, logging.getLevelName(level))56 self.add_file_handler(file_name, level=level, log_dir=log_dir)57 def add_debug_file_handlers(self, log_dir, log_name=None):58 raise NotImplementedError59 def _clear_all_handlers(self):60 for handler in list(self.logger.handlers):61 self.logger.removeHandler(handler)62 # Attempt to close the handler. If it's already closed a KeyError63 # will be generated. http://bugs.python.org/issue858164 try:65 handler.close()66 except KeyError:67 pass68 def configure_logging(self, use_console=True, verbose=False):69 self._clear_all_handlers() # see comment at top of file70 self.logger.setLevel(self.global_level)71 if verbose:72 self.stdout_level = logging.DEBUG73 if use_console:...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful