How to use _get_log_dir method in robotframework-appiumlibrary

Best Python code snippet using robotframework-appiumlibrary_python

logging_utils.py

Source:logging_utils.py Github

copy

Full Screen

1import logging2import json3import os4def set_default_logging(parent_dir, level=logging.INFO):5 os.makedirs(_get_log_dir(parent_dir), exist_ok=True)6 log_file = f"{_get_log_dir(parent_dir)}/wm_logs.log"7 all_log_handler = logging.FileHandler(log_file)8 console_handler = logging.StreamHandler()9 logging.basicConfig(format="%(asctime)s;%(levelname)s;%(message)s",10 datefmt='%Y-%m-%d,%H:%M:%S',11 level=level,12 handlers=[all_log_handler, console_handler])13def get_error_logger(action_type, object_type, log_dir):14 """15 Failures are written to object specific log file.16 """17 logger = logging.getLogger("workspace_migration")18 failed_log_file = get_error_log_file(action_type, object_type, log_dir)19 os.makedirs(_get_log_dir(log_dir), exist_ok=True)20 error_handler = logging.FileHandler(failed_log_file, 'w+')21 error_handler.setLevel(logging.ERROR)22 logger.addHandler(error_handler)23 return logger24def get_error_log_file(action_type, object_type, parent_dir):25 return f"{_get_log_dir(parent_dir)}/failed_{action_type}_{object_type}.log"26def _get_log_dir(parent_dir):27 return parent_dir + "/app_logs"28default_ignore_error_list=[29 'RESOURCE_ALREADY_EXISTS'30]31def log_reponse_error(error_logger,32 response,33 error_msg=None,34 ignore_error_list=default_ignore_error_list):35 """36 Logs errors based on the response. Usually used when the response is the http response.37 """38 if check_error(response, ignore_error_list):39 if error_msg:40 error_logger.error(error_msg)...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...5import logging6from bcbio import utils7LOG_NAME = "nextgen_pipeline"8logger = logging.getLogger(LOG_NAME)9def _get_log_dir(config):10 d = config.get("log_dir",11 config.get("resources", {}).get("log", {}).get("dir", "log"))12 return d13def setup_logging(config):14 logger.setLevel(logging.INFO)15 if not logger.handlers:16 formatter = logging.Formatter('[%(asctime)s] %(message)s')17 handler = logging.StreamHandler()18 handler.setFormatter(formatter)19 logger.addHandler(handler)20 log_dir = _get_log_dir(config)21 if log_dir:22 logfile = os.path.join(utils.safe_makedir(log_dir),23 "{0}.log".format(LOG_NAME))24 handler = logging.FileHandler(logfile)25 handler.setFormatter(formatter)26 logger.addHandler(handler)27import logbook28logger2 = logbook.Logger(LOG_NAME)29def create_log_handler(config):30 log_dir = _get_log_dir(config)31 email = config.get("email", config.get("resources", {}).get("log", {}).get("email"))32 if log_dir:33 utils.safe_makedir(log_dir)34 handler = logbook.FileHandler(os.path.join(log_dir, "%s.log" % LOG_NAME))35 else:36 handler = logbook.StreamHandler(sys.stdout)37 if email:38 handler = logbook.MailHandler(email, [email],39 format_string=u'''Subject: [BCBB pipeline] {record.extra[run]} \n\n {record.message}''',40 level='INFO', bubble = True)...

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 robotframework-appiumlibrary 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