How to use split_loggers_and_levels method in avocado

Best Python code snippet using avocado_python Github


Full Screen

...146 :type config: dict147 :param queue: queue for the runner messages148 :type queue: multiprocessing.SimpleQueue149 """150 def split_loggers_and_levels(enabled_loggers, default_level):151 for logger_level_split in map(lambda x: x.split(":"), enabled_loggers):152 logger_name, *level = logger_level_split153 yield logger_name, level[0] if len(level) > 0 else default_level154 log_level = config.get("job.output.loglevel", logging.DEBUG)155 log_handler = RunnerLogHandler(queue, "log")156 fmt = "%(asctime)s %(name)s %(levelname)-5.5s| %(message)s"157 formatter = logging.Formatter(fmt=fmt)158 log_handler.setFormatter(formatter)159 # main log = 'avocado'160 logger = logging.getLogger("avocado")161 logger.addHandler(log_handler)162 logger.setLevel(log_level)163 logger.propagate = False164 # LOG_JOB = 'avocado.test'165 log = output.LOG_JOB166 log.addHandler(log_handler)167 log.setLevel(log_level)168 log.propagate = False169 # LOG_UI = ''170 output.LOG_UI.addHandler(RunnerLogHandler(queue, "stdout"))171 sys.stdout = StreamToQueue(queue, "stdout")172 sys.stderr = StreamToQueue(queue, "stderr")173 # output custom test loggers174 enabled_loggers = config.get("")175 output_handler = RunnerLogHandler(queue, "output")176 output_handler.setFormatter(logging.Formatter(fmt="%(name)s: %(message)s"))177 user_streams = [178 user_streams179 for user_streams in enabled_loggers180 if user_streams not in BUILTIN_STREAMS181 ]182 for user_stream, level in split_loggers_and_levels(user_streams, log_level):183 custom_logger = logging.getLogger(user_stream)184 custom_logger.addHandler(output_handler)185 custom_logger.setLevel(level)186 # store custom test loggers187 enabled_loggers = config.get("")188 for enabled_logger, level in split_loggers_and_levels(enabled_loggers, log_level):189 store_stream_handler = RunnerLogHandler(queue, "file", {"path": enabled_logger})190 store_stream_handler.setFormatter(formatter)191 output_logger = logging.getLogger(enabled_logger)192 output_logger.addHandler(store_stream_handler)193 output_logger.setLevel(level)194 if not enabled_logger.startswith("avocado."):195 output_logger.addHandler(log_handler)...

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:


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

Run avocado 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?